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 44c0eba84..791d679b3 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -141,8 +141,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private int eastRegionToolPaneY = 300; private int eastRegionContainerWidth = 260; + private int westRegionToolPaneY = 300; private int westRegionContainerWidth = 240; - private double westRegionToolPaneYRate = 0.5; private String encryptionKey; private String jdkHome; @@ -240,7 +240,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String installHome = StableUtils.getInstallHome(); //这里不判断路径是.的情况,放在checkValid方法里面,重新选 if (installHome != null) { - String name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_DEFAULT"); + String name = Toolkit.i18nText("Fine-Design_Basic_Engine_DEFAULT"); String envPath = designerEnvManager.getDefaultenvPath(installHome); designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath)); designerEnvManager.setCurEnvName(name); @@ -304,8 +304,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String today = calender.get(Calendar.YEAR) + "-" + (calender.get(Calendar.MONTH) + 1) + "-" + calender.get(Calendar.DAY_OF_MONTH); String fileName = StableUtils.pathJoin(logLocation, "fr_" + today + "_%g.log"); - if (!new java.io.File(fileName).exists()) { - StableUtils.makesureFileExist(new java.io.File(fileName)); + if (!new File(fileName).exists()) { + StableUtils.makesureFileExist(new File(fileName)); } Handler handler = new FileHandler(fileName, true); @@ -440,12 +440,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.lastOpenFilePath = lastOpenFilePath; } + /** - * 获取西面板的上子面板的高度占容器总高度的比例 + * 得到西面板的上下子面板的高度区分 + * * @return */ - public double getLastWestRegionToolPaneYRate() { - return westRegionToolPaneYRate; + public int getLastWestRegionToolPaneY() { + return this.westRegionToolPaneY; } /** @@ -458,11 +460,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } /** - * 设置关闭设计器前,西面板的上子面板的高度占容器总高度的比例 - * @param westRegionToolPaneYRate + * 设置西面板的上下子面板的高度区分 + * + * @param toolPaneY */ - public void setLastWestRegionToolPaneYRate(double westRegionToolPaneYRate) { - this.westRegionToolPaneYRate = westRegionToolPaneYRate; + public void setLastWestRegionToolPaneY(int toolPaneY) { + this.westRegionToolPaneY = toolPaneY; } /** @@ -526,7 +529,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return env; } } - String name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); + String name = Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); LocalDesignerWorkspaceInfo newDefaultEnv = LocalDesignerWorkspaceInfo.create(name, defaultenvPath); this.putEnv(name, newDefaultEnv); return newDefaultEnv; @@ -549,7 +552,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } } - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); + return Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); } @@ -1607,8 +1610,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void readLastWestRegionLayout(XMLableReader reader) { String tmpVal; - if ((tmpVal = reader.getAttrAsString("toolPaneYRate", null)) != null) { - this.setLastWestRegionToolPaneYRate(Double.parseDouble(tmpVal)); + if ((tmpVal = reader.getAttrAsString("toolPaneY", null)) != null) { + this.setLastWestRegionToolPaneY(Integer.parseInt(tmpVal)); } if ((tmpVal = reader.getAttrAsString("containerWidth", null)) != null) { this.setLastWestRegionContainerWidth(Integer.parseInt(tmpVal)); @@ -1640,7 +1643,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) { // marks:兼容6.1的 // marks:设置默认的目录. - String curReportServerName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server"); + String curReportServerName = Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server"); LocalDesignerWorkspaceInfo reportServer = LocalDesignerWorkspaceInfo.create(curReportServerName, tmpVal); this.putEnv(curReportServerName, reportServer); @@ -1931,8 +1934,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void writeLastWestRegionLayout(XMLPrintWriter writer) { writer.startTAG("LastWestRegionLayout"); - if (this.getLastWestRegionToolPaneYRate() >= 0) { - writer.attr("toolPaneYRate", this.getLastWestRegionToolPaneYRate()); + if (this.getLastWestRegionToolPaneY() >= 0) { + writer.attr("toolPaneY ", this.getLastWestRegionToolPaneY()); } if (this.getLastWestRegionContainerWidth() >= 0) { writer.attr("containerWidth", this.getLastWestRegionContainerWidth()); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java index 2c0612e02..b3ad1e179 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java @@ -142,6 +142,7 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { this.model.clear(); this.model.addAll(dependenceList); + this.model.fireTableDataChanged(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index b48950485..f3f45768f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -44,7 +44,6 @@ public class UIResizableContainer extends JPanel { private boolean isDownPaneVisible = true ; private int paraHeight; private int parentHeight = -1; - private double toolPaneYRate; public UIResizableContainer(int direction) { this(new JPanel(), new JPanel(), direction); @@ -157,20 +156,12 @@ public class UIResizableContainer extends JPanel { return this.toolPaneY; } - /** - * 获取上子面板高度占容器总高度的比例 - * @return - */ - public double getToolPaneYRate() { - return toolPaneYRate; - } - /** * 设置关闭设计器前最新的上子面板的高度比例 - * @param toolPaneYRate + * @param toolPaneY */ - public void setLastToolPaneYRate(double toolPaneYRate) { - this.toolPaneYRate = toolPaneYRate; + public void setLastToolPaneY(int toolPaneY) { + this.toolPaneY = toolPaneY; } /** @@ -248,9 +239,10 @@ public class UIResizableContainer extends JPanel { if (parentHeight == -1) { // 初始化下parentheight,存一下当前的父容器height parentHeight = parent.getHeight(); - } else if (parentHeight != parent.getHeight() && parent.getHeight() > 0) { - // parentHeight与父容器height不等时,代表用户调整分辨率或者dpi或者容器高度发生变化了,此时调整toolPaneY - toolPaneY = Math.min((int) (parent.getHeight() * toolPaneYRate), (parent.getHeight() - toolPaneHeight)); + } + if (parentHeight != parent.getHeight() && (parent.getHeight() - toolPaneHeight) >= 0) { + // 调整toolPaneY,保证至少水平的拖拽条horizontToolPane不丢失 + toolPaneY = Math.min(toolPaneY, parent.getHeight() - toolPaneHeight); parentHeight = parent.getHeight(); } } @@ -376,7 +368,6 @@ public class UIResizableContainer extends JPanel { toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); - adjustToolPaneYRate(); refreshContainer(); } }); @@ -398,10 +389,8 @@ public class UIResizableContainer extends JPanel { public void mouseClicked(MouseEvent e) { if (e.getX() <= ARROW_RANGE) { toolPaneY = 0; - UIResizableContainer.this.adjustToolPaneYRate(); } else if (e.getX() >= getWidth() - ARROW_RANGE) { toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight(); - UIResizableContainer.this.adjustToolPaneYRate(); } else { return; } @@ -562,11 +551,4 @@ public class UIResizableContainer extends JPanel { jf.setSize(500, 500); jf.setVisible(true); } - - /** - * 当toolPaneY发生变化时,也需要调整toolPaneYRate - */ - private void adjustToolPaneYRate() { - this.toolPaneYRate = ((double) toolPaneY) / this.getHeight(); - } } 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 a5eafa0c0..490b4e7e9 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 @@ -1170,8 +1170,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); } - DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneYRate( - WestRegionContainerPane.getInstance().getToolPaneYRate()); + DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( + WestRegionContainerPane.getInstance().getToolPaneY()); DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( WestRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( 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 0703216eb..a95b92400 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 @@ -18,6 +18,7 @@ import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.general.FRFont; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; import com.fr.plugin.injectable.PluginModule; @@ -100,14 +101,29 @@ public class EastRegionContainerPane extends UIEastResizableContainer { REPORT, // 报表 REPORT_PARA, // 报表参数面板 REPORT_FLOAT, // 报表悬浮元素 - FORM, // 表单 + FORM(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings")), // 表单 FORM_REPORT, // 表单报表块 POLY, // 聚合报表 POLY_REPORT, // 聚合报表-报表块 POLY_CHART, // 聚合报表-图表块 AUTHORITY_EDITION, // 权限编辑 - AUTHORITY_EDITION_DISABLED // 权限编辑 + AUTHORITY_EDITION_DISABLED; // 权限编辑 + + private String title; + + PropertyMode() { + this.title = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Settings"); + } + + PropertyMode(String title) { + this.title = title; + } + + public String getTitle() { + return this.title; + } } + private PropertyMode currentMode; // 当前模式(根据不同模式,显示不同的可用面板) @@ -400,6 +416,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private void updatePropertyItemMap() { for (PropertyItem item : propertyItemMap.values()) { item.updateStatus(); + item.updateTitle(); } } @@ -734,6 +751,19 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } } + public void updateTitle() { + try { + if (StringUtils.equals(KEY_WIDGET_SETTINGS, name)) { + title = currentMode.getTitle(); + button.setToolTipText(title); + UILabel uiLabel = (UILabel) ((BorderLayout) popupToolPane.contentPane.getLayout()).getLayoutComponent(BorderLayout.WEST); + uiLabel.setText(title); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } + } + public void reAddContentArea() { propertyPanel.add(contentArea, BorderLayout.CENTER); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java index 358fba411..004fbd55a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java @@ -24,7 +24,7 @@ public class WestRegionContainerPane extends UIResizableContainer { public static final WestRegionContainerPane getInstance() { if (THIS == null) { THIS = new WestRegionContainerPane(); - THIS.setLastToolPaneYRate(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneYRate()); + THIS.setLastToolPaneY(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneY()); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth()); } return THIS; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java index 099684a81..23cc188ed 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java @@ -4,6 +4,7 @@ import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -56,20 +57,24 @@ public class BasicPropertyPane extends BasicPane { } } }; - widgetName.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic")); + widgetName.setGlobalName(Toolkit.i18nText("Fine-Design_Report_Basic")); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Name")), widgetName}, + new Component[]{new UILabel(obtainBasicName()), widgetName}, }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); this.add(panel, BorderLayout.NORTH); } + public String obtainBasicName(){ + return Toolkit.i18nText("Fine-Design_Basic_Component_Name"); + } + public UITextField getWidgetNameField() { return widgetName; } diff --git a/designer-base/src/main/java/com/fr/design/preview/FormPreview.java b/designer-base/src/main/java/com/fr/design/preview/FormPreview.java index 8522d6773..178779f51 100644 --- a/designer-base/src/main/java/com/fr/design/preview/FormPreview.java +++ b/designer-base/src/main/java/com/fr/design/preview/FormPreview.java @@ -1,6 +1,7 @@ package com.fr.design.preview; import com.fr.design.fun.impl.AbstractPreviewProvider; +import com.fr.design.i18n.Toolkit; /** @@ -12,7 +13,7 @@ public class FormPreview extends AbstractPreviewProvider { @Override public String nameForPopupItem() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Form_Preview"); + return Toolkit.i18nText("Fine-Design_Form_M_PC_Preview"); } @Override diff --git a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java index c24125059..06770c1b4 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java @@ -4,6 +4,7 @@ import com.fr.design.actions.JTemplateAction; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.UIDialog; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuKeySet; @@ -26,7 +27,7 @@ public class ReportFitAttrAction extends JTemplateAction { @Override public String getMenuName() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Template"); + return Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"); } @Override @@ -42,7 +43,7 @@ public class ReportFitAttrAction extends JTemplateAction { @Override public String getMenuName() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Elementcase"); + return Toolkit.i18nText("Fine-Designer_PC_Element_Case_Fit_Attr"); } @Override diff --git a/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java b/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java index c4c840227..9b2b64d09 100644 --- a/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java @@ -4,6 +4,7 @@ import com.fr.design.designer.IntervalConstants; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -25,8 +26,8 @@ public class WidgetBoundsPaneFactory { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)}, - new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, + new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)}, + new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, }; double[] rowSize = {p, p}; double[] columnSize = {f, RIGHT_PANE_WIDTH}; @@ -34,7 +35,7 @@ public class WidgetBoundsPaneFactory { final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W5, IntervalConstants.INTERVAL_L6); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); boundsPane.add(panel); - return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 280, 24, boundsPane); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 280, 24, boundsPane); } public static JPanel createRightPane(Component com1, Component com2){ double f = TableLayout.FILL; @@ -53,12 +54,12 @@ public class WidgetBoundsPaneFactory { double p = TableLayout.PREFERRED; Component[][] northComponents = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Position")), createRightPane(x, y)}, - new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER))}, + new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Widget_Position")), createRightPane(x, y)}, + new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER))}, }; Component[][] centerComponents = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)}, - new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, + new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), createRightPane(width, height)}, + new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, }; double[] rowSize = {p, p}; double[] columnSize = {f, RIGHT_PANE_WIDTH}; @@ -70,7 +71,7 @@ public class WidgetBoundsPaneFactory { centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); boundsPane.add(northPanel, BorderLayout.NORTH); boundsPane.add(centerPanel, BorderLayout.CENTER); - return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 230, 24, boundsPane); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 230, 24, boundsPane); } @@ -79,7 +80,7 @@ public class WidgetBoundsPaneFactory { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), width}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Component_Size")), width}, }; double[] rowSize = {p}; double[] columnSize = {p, f}; @@ -87,6 +88,6 @@ public class WidgetBoundsPaneFactory { final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L6); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); boundsPane.add(panel); - return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 280, 24, boundsPane); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 280, 24, boundsPane); } } diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index ccf01dd5e..46b11d2a8 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -53,7 +53,6 @@ import javax.swing.BorderFactory; import javax.swing.DefaultCellEditor; import javax.swing.DefaultComboBoxModel; import javax.swing.Icon; -import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -74,6 +73,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.Image; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusAdapter; @@ -92,136 +92,133 @@ public class DBManipulationPane extends BasicBeanPane { private static final Image ICODS_IMAGE = BaseUtils.readImage("/com/fr/web/core/css/images/icons.png"); private static final Icon HEIP_ICON = BaseUtils.createIcon(ICODS_IMAGE, 193, 1, 14, 14); private static final int DEFAULT_RETURN_VALUE = 4; - public KeyColumnNameValueTable keyColumnValuesTable; - private UIComboBox columnsComboBox; // 用于编辑ColumnName的Editor + public KeyColumnNameValueTable keyColumnValuesTable; + private UIComboBox columnsComboBox; // 用于编辑ColumnName的Editor private UICheckBox UpdateCheckBox; private JPanel checkBoxUpdatePane; - /* - * 记录当前选取的DS & Table对应的ColumnName[] - * alex:以前每当tableNameComboBox改变就刷新columnsComboBox,这样每输入一个文字就会刷一遍,很不好 - */ - private ColumnName[] currentColumnNames = null; + /* + * 记录当前选取的DS & Table对应的ColumnName[] + * alex:以前每当tableNameComboBox改变就刷新columnsComboBox,这样每输入一个文字就会刷一遍,很不好 + */ + private ColumnName[] currentColumnNames = null; - // 支持公式输入的数据表选择面板 - private ChoosePaneSupportFormula chooseTable; + // 支持公式输入的数据表选择面板 + private ChoosePaneSupportFormula chooseTable; - private UIComboBox dmlConfigComboBox = null; + private UIComboBox dmlConfigComboBox = null; - // 提交事件 - private NameSubmitJob[] jobs = null; + // 提交事件 + private NameSubmitJob[] jobs = null; - // 提交条件 - private Condition condition = null; + // 提交条件 + private Condition condition = null; - private JTree conditionsTree; + private JTree conditionsTree; - private Editor[] v_Types; + private Editor[] v_Types; - protected JavaScriptActionPane parentPane; + protected JavaScriptActionPane parentPane; - private int keyColumnWidth = 100; - private int resizeColumnCount = 4; - private int btnWidth = 110; - private int btnHeight = 20; private String subMitName; - private static final String[] DML_CONFIG_TYPES = new String[] { + private static final String[] DML_CONFIG_TYPES = new String[]{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Smart_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Delete_Submit"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Update_Submit")}; - /** - * 无单元格。没有智能添加单元格等按钮 - * 有单元格的参见其子类SmartInsertDBManipulationPane - */ - public DBManipulationPane() { - this(ValueEditorPaneFactory.extendedCellGroupEditors()); - } + /** + * 无单元格。没有智能添加单元格等按钮 + * 有单元格的参见其子类SmartInsertDBManipulationPane + */ + public DBManipulationPane() { + this(ValueEditorPaneFactory.extendedCellGroupEditors()); + } - public DBManipulationPane(Editor[] v_Types) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.v_Types = v_Types; + public DBManipulationPane(Editor[] v_Types) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.v_Types = v_Types; - JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(northPane, BorderLayout.NORTH); + JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(northPane, BorderLayout.NORTH); - dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); + dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); - JPanel typePane = GUICoreUtils.createFlowPane(new Component[] { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox }, - FlowLayout.LEFT, 10); - typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); - northPane.add(typePane, BorderLayout.NORTH); + JPanel typePane = GUICoreUtils.createFlowPane(new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox}, + FlowLayout.LEFT, 10); + typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); + northPane.add(typePane, BorderLayout.NORTH); - chooseTable = new ChoosePaneSupportFormula(); - chooseTable.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Table"))); - chooseTable.setTableNameComboBoxPopSize(160, 320); + chooseTable = new ChoosePaneSupportFormula(); + chooseTable.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Table"))); + chooseTable.setTableNameComboBoxPopSize(160, 320); - northPane.add(chooseTable, BorderLayout.CENTER); + northPane.add(chooseTable, BorderLayout.CENTER); - // peter:编辑的TablePane - JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(editTablePane, BorderLayout.CENTER); - editTablePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"))); + // peter:编辑的TablePane + JPanel editTablePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(editTablePane, BorderLayout.CENTER); + editTablePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"))); - keyColumnValuesTable = new KeyColumnNameValueTable(); - editTablePane.add(new JScrollPane(this.keyColumnValuesTable), BorderLayout.CENTER); - keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - keyColumnValuesTable.setPreferredScrollableViewportSize(new Dimension(280, 180)); - keyColumnValuesTable.setShowHorizontalLines(true); + keyColumnValuesTable = new KeyColumnNameValueTable(); + editTablePane.add(new JScrollPane(this.keyColumnValuesTable), BorderLayout.CENTER); + keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + keyColumnValuesTable.setPreferredScrollableViewportSize(new Dimension(280, 180)); + keyColumnValuesTable.setShowHorizontalLines(true); - initJTableColumn(); + initJTableColumn(); - addButtons(editTablePane); + addButtons(editTablePane); - addBottomPane(); + addBottomPane(); - addListeners(); - } + addListeners(); + } - public void setSubMitName(String subMitName){ + public void setSubMitName(String subMitName) { this.subMitName = subMitName; } - public String getSubMitName(){ + public String getSubMitName() { return this.subMitName; } - private void addButtons(JPanel editTablePane) { - // alex:添加操作按钮 - UpdateAction[] actions = this.getActions(); - if (actions != null && actions.length > 0) { - JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); - editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); + private void addButtons(JPanel editTablePane) { + // alex:添加操作按钮 + UpdateAction[] actions = this.getActions(); + if (actions != null && actions.length > 0) { + JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); + editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); - for (int i = 0; i < actions.length; i++) { - controlBtnPane.add(new UIButton(actions[i])); - } + for (UpdateAction action : actions) { + controlBtnPane.add(new UIButton(action)); + } checkBoxUpdatePane = new JPanel(new BorderLayout(0, 0)); - checkBoxUpdatePane.setPreferredSize(new Dimension(120,20)); + checkBoxUpdatePane.setPreferredSize(new Dimension(120, 20)); controlBtnPane.add(checkBoxUpdatePane); UpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_NotChange_Unmodified")); - UIButton helpButton = new UIButton(HEIP_ICON); + UIButton helpButton = new UIButton(HEIP_ICON); helpButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help")); helpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); + FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); BasicDialog dlg = formatExplanation.showMediumWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), - new DialogActionAdapter(){}); + new DialogActionAdapter() { + }); dlg.setVisible(true); } }); helpButton.set4ToolbarButton(); - checkBoxUpdatePane.add(UpdateCheckBox,BorderLayout.WEST); - checkBoxUpdatePane.add(helpButton,BorderLayout.EAST); - } - } - - protected void updateUpdateCheckBoxEnable(){ - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - if (model.getRowCount() == 0){ + checkBoxUpdatePane.add(UpdateCheckBox, BorderLayout.WEST); + checkBoxUpdatePane.add(helpButton, BorderLayout.EAST); + } + } + + protected void updateUpdateCheckBoxEnable() { + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + if (model.getRowCount() == 0) { setUpdateCheckBoxEnable(false); UpdateCheckBox.setSelected(true); return; @@ -230,9 +227,8 @@ public class DBManipulationPane extends BasicBeanPane { for (int i = 0; i < model.getRowCount(); i++) { columnObjects.add(model.getKeyColumnNameValue(i).cv.getObj()); } - for (int i = 0;i < columnObjects.size();i++){ - Object ob = columnObjects.get(i) ; - if (!( ob instanceof ColumnRow || ob instanceof ColumnRowGroup)){ + for (Object ob : columnObjects) { + if (!(ob instanceof ColumnRow || ob instanceof ColumnRowGroup)) { setUpdateCheckBoxEnable(false); UpdateCheckBox.setSelected(false); return; @@ -241,236 +237,241 @@ public class DBManipulationPane extends BasicBeanPane { setUpdateCheckBoxEnable(true); } - private void setUpdateCheckBoxEnable( boolean b){ + private void setUpdateCheckBoxEnable(boolean b) { UpdateCheckBox.setEnabled(b); } - private void addBottomPane() { - JPanel eventPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - eventPane.add(addEventButton()); + private void addBottomPane() { + JPanel eventPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + eventPane.add(addEventButton()); - JPanel conditionPane = this.createConditionPane(); + JPanel conditionPane = this.createConditionPane(); - JPanel btPane =new JPanel( FRGUIPaneFactory.createBorderLayout()); - btPane.add(eventPane,BorderLayout.CENTER); - btPane.add(conditionPane,BorderLayout.NORTH); - this.add(btPane, BorderLayout.SOUTH); - } + JPanel btPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); + btPane.add(eventPane, BorderLayout.CENTER); + btPane.add(conditionPane, BorderLayout.NORTH); + this.add(btPane, BorderLayout.SOUTH); + } - private UIButton addEventButton() { - UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); - addSubmitEventButton.addActionListener(new ActionListener() { + private UIButton addEventButton() { + UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); + addSubmitEventButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final SubmitJobListPane jobsPane = createSubmitJobListPane(); + @Override + public void actionPerformed(ActionEvent e) { + final SubmitJobListPane jobsPane = createSubmitJobListPane(); - jobsPane.populate(jobs); - BasicDialog dialog = jobsPane.showWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { - @Override - public void doOk() { - super.doOk(); - jobs = jobsPane.updateDBManipulation(); - } - }); - dialog.setVisible(true); - } + jobsPane.populate(jobs); + BasicDialog dialog = jobsPane.showWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + jobs = jobsPane.updateDBManipulation(); + } + }); + dialog.setVisible(true); + } - }); - return addSubmitEventButton; - } + }); + return addSubmitEventButton; + } - private JPanel createConditionPane() { - JPanel conditionPane = new JPanel(); - conditionPane.setPreferredSize(createConditionPanePreferredSize()); + private JPanel createConditionPane() { + JPanel conditionPane = new JPanel(); + conditionPane.setPreferredSize(createConditionPanePreferredSize()); setBorderAndLayout(conditionPane); - conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode())); - conditionsTree.setRootVisible(false); - conditionsTree.setShowsRootHandles(true); - conditionsTree.setBackground(UIConstants.NORMAL_BACKGROUND); - conditionsTree.setForeground(UIConstants.NORMAL_BACKGROUND); - DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); - cr.setForeground(UIConstants.NORMAL_BACKGROUND); - JScrollPane jp = new JScrollPane(conditionsTree); - addComponent(conditionPane,jp); - - UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); - addSubmitConditionButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { - @Override - protected boolean isNeedDoWithCondition(Condition liteCondition) { - return liteCondition != null; - } - }; - String[] columns = chooseTable.currentColumnNames(); - if (columns != null && columns.length > 0) { - conditionPane.populateColumns(chooseTable.currentColumnNames()); - } - - conditionPane.populateBean(condition); - BasicDialog dialog = conditionPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - super.doOk(); - condition = conditionPane.updateBean(); - refreshConditionList(); - } - }); - dialog.setVisible(true); - } - }); - - JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); + conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode())); + conditionsTree.setRootVisible(false); + conditionsTree.setShowsRootHandles(true); + conditionsTree.setBackground(UIConstants.NORMAL_BACKGROUND); + conditionsTree.setForeground(UIConstants.NORMAL_BACKGROUND); + DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); + cr.setForeground(UIConstants.NORMAL_BACKGROUND); + JScrollPane jp = new JScrollPane(conditionsTree); + addComponent(conditionPane, jp); + + UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); + addSubmitConditionButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { + @Override + protected boolean isNeedDoWithCondition(Condition liteCondition) { + return liteCondition != null; + } + }; + String[] columns = chooseTable.currentColumnNames(); + if (columns != null && columns.length > 0) { + conditionPane.populateColumns(chooseTable.currentColumnNames()); + } + + conditionPane.populateBean(condition); + BasicDialog dialog = conditionPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + condition = conditionPane.updateBean(); + refreshConditionList(); + } + }); + dialog.setVisible(true); + } + }); + + JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); controlBtnPane.setPreferredSize(createControlBtnPanePreferredSize()); - conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH),setControlBtnPanePosition()); - controlBtnPane.add(addSubmitConditionButton); + conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), setControlBtnPanePosition()); + controlBtnPane.add(addSubmitConditionButton); - return conditionPane; - } + return conditionPane; + } - protected void setBorderAndLayout(JPanel jPanel){ + protected void setBorderAndLayout(JPanel jPanel) { jPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); jPanel.setBorder(BorderFactory.createTitledBorder( - new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); + new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); } - protected void addComponent(JPanel mainPane,JScrollPane addPane){ - mainPane.add(addPane,BorderLayout.CENTER); + protected void addComponent(JPanel mainPane, JScrollPane addPane) { + mainPane.add(addPane, BorderLayout.CENTER); } - protected Dimension createConditionPanePreferredSize(){ + protected Dimension createConditionPanePreferredSize() { return new Dimension(454, 80); } - protected Dimension createControlBtnPanePreferredSize(){ + protected Dimension createControlBtnPanePreferredSize() { return new Dimension(110, 20); } - protected String setControlBtnPanePosition(){ - return BorderLayout.EAST; + protected String setControlBtnPanePosition() { + return BorderLayout.EAST; + } + + private void refreshConditionList() { + DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel(); + ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); + rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition())); + rootTreeNode.removeAllChildren(); + Condition liteCondition = this.condition == null ? new ListCondition() : this.condition; + if (liteCondition instanceof ListCondition) { + ListCondition listCondition = (ListCondition) liteCondition; + int joinConditionCount = listCondition.getJoinConditionCount(); + for (int i = 0; i < joinConditionCount; i++) { + addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i)); + } + } else { + ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition)); + rootTreeNode.add(newTreeNode); + } + defaultTreeModel.reload(rootTreeNode); + rootTreeNode.expandCurrentTreeNode(conditionsTree); + } + + private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) { + ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition); + parentTreeNode.add(newTreeNode); + Condition liteCondition = joinCondition.getCondition(); + if (liteCondition instanceof ListCondition) { + ListCondition listCondition = (ListCondition) liteCondition; + int joinConditionCount = listCondition.getJoinConditionCount(); + for (int i = 0; i < joinConditionCount; i++) { + addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i)); + } + } + } + + private void addListeners() { + dmlConfigComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + Object ob = e.getItem(); + if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[0])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[3])) { + checkBoxUpdatePane.setVisible(true); + } else if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[1])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[2])) { + checkBoxUpdatePane.setVisible(false); + } + } + } + }); + + /* + * 当DS & Table改变时要刷新ColumnsComboBox.model,不能用ItemListener, + * 因为tableNameComboBox是可以编辑的,每写一个文字就要连,太频繁了 + * 也不能在tableNameComboBox.focusLost事件时,好像没用 + */ + keyColumnValuesTable.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(FocusEvent e) { + refreshColumnsComboBox(); + } + + }); + } + + protected UpdateAction[] getActions() { + return new UpdateAction[]{new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction()}; + } + + protected SubmitJobListPane createSubmitJobListPane() { + return new SubmitJobListPane(); + } + + public void setParentJavaScriptActionPane(JavaScriptActionPane jsPane) { + this.parentPane = jsPane; + } + + @Override + protected String title4PopupWindow() { + return "DB"; } - private void refreshConditionList() { - DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel(); - ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); - rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition())); - rootTreeNode.removeAllChildren(); - Condition liteCondition = this.condition == null ? new ListCondition() : this.condition; - if (liteCondition instanceof ListCondition) { - ListCondition listCondition = (ListCondition) liteCondition; - int joinConditionCount = listCondition.getJoinConditionCount(); - for (int i = 0; i < joinConditionCount; i++) { - addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i)); - } - } else { - ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition)); - rootTreeNode.add(newTreeNode); - } - defaultTreeModel.reload(rootTreeNode); - rootTreeNode.expandCurrentTreeNode(conditionsTree); - } - - private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) { - ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition); - parentTreeNode.add(newTreeNode); - Condition liteCondition = joinCondition.getCondition(); - if (liteCondition instanceof ListCondition) { - ListCondition listCondition = (ListCondition) liteCondition; - int joinConditionCount = listCondition.getJoinConditionCount(); - for (int i = 0; i < joinConditionCount; i++) { - addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i)); - } - } - } - - private void addListeners() { - dmlConfigComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - Object ob = e.getItem(); - if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[0])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[3])) { - checkBoxUpdatePane.setVisible(true); - } else if ((ComparatorUtils.equals(ob, DML_CONFIG_TYPES[1])) || ComparatorUtils.equals(ob, DML_CONFIG_TYPES[2])) { - checkBoxUpdatePane.setVisible(false); - } - } - } - }); - - /* - * 当DS & Table改变时要刷新ColumnsComboBox.model,不能用ItemListener, - * 因为tableNameComboBox是可以编辑的,每写一个文字就要连,太频繁了 - * 也不能在tableNameComboBox.focusLost事件时,好像没用 - */ - keyColumnValuesTable.addFocusListener(new FocusAdapter() { - - public void focusGained(FocusEvent e) { - refreshColumnsComboBox(); - } - - }); - } - - protected UpdateAction[] getActions() { - return new UpdateAction[] { new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction() }; - } - - protected SubmitJobListPane createSubmitJobListPane() { - return new SubmitJobListPane(); - } - - public void setParentJavaScriptActionPane(JavaScriptActionPane jsPane) { - this.parentPane = jsPane; - } - - @Override - protected String title4PopupWindow() { - return "DB"; - } - - protected class SmartAddFieldsAction extends UpdateAction { - public SmartAddFieldsAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); - } - - public void actionPerformed(ActionEvent evt) { - - BasicPane bPane = new BasicPane() { - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"); - } - }; - bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - - final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { - public String value2Text(Object value) { - if (value instanceof ColumnName) { - return ((ColumnName)value).name; - } - - return super.value2Text(value); - } - }; - bPane.add(new JScrollPane(list), BorderLayout.CENTER); - - BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { - public void doOk() { - addFields(list); + protected class SmartAddFieldsAction extends UpdateAction { + public SmartAddFieldsAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + + BasicPane bPane = new BasicPane() { + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"); + } + }; + bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + + final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { + @Override + public String value2Text(Object value) { + if (value instanceof ColumnName) { + return ((ColumnName) value).name; + } + + return super.value2Text(value); + } + }; + bPane.add(new JScrollPane(list), BorderLayout.CENTER); + + BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { + @Override + public void doOk() { + addFields(list); updateUpdateCheckBoxEnable(); - } - }); - dlg.setVisible(true); - } - } - - private void addFields (CheckBoxList list) { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); + } + }); + dlg.setVisible(true); + } + } + + private void addFields(CheckBoxList list) { + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); List keyColumnNameValueList = new ArrayList(); keyColumnNameValueList.clear(); for (int i = 0; i < model.getRowCount(); i++) { @@ -481,28 +482,28 @@ public class DBManipulationPane extends BasicBeanPane { // Richie:用了存储新的KeyColumnNameValue的List. List newKeyColumnNameValueList = new ArrayList(); if (!keyColumnNameValueList.isEmpty()) { - for (int i = 0; i < selected.length; i++) { + for (Object o : selected) { // Richie:先填上空的. - newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); + newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false)); } } // Richie:初始化 int returnValue = DEFAULT_RETURN_VALUE; int coverNumber = 0; - if (!keyColumnNameValueList.isEmpty()) { - //如果存在先前项,设置状态为5 - returnValue = 5 ; - } + if (!keyColumnNameValueList.isEmpty()) { + //如果存在先前项,设置状态为5 + returnValue = 5; + } for (int i = 0; i < selected.length; i++) { if (returnValue == 0 || returnValue == 3) { break; } - for (int j = 0; j < keyColumnNameValueList.size(); j++) { - if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { - Object[] options = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None") }; + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) { + Object[] options = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None")}; returnValue = JOptionPane.showOptionDialog(DBManipulationPane.this, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValueList.get(j).cn.name), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValue.cn.name), "", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); // Richie:全部覆盖 if (returnValue == 0) { @@ -514,7 +515,7 @@ public class DBManipulationPane extends BasicBeanPane { } else if (returnValue == 2) { coverNumber = i; newKeyColumnNameValueList.remove(i); - newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); + newKeyColumnNameValueList.add(i, keyColumnNameValue); // Richie:全部不覆盖 } else if (returnValue == 3) { coverNumber = i; @@ -526,7 +527,7 @@ public class DBManipulationPane extends BasicBeanPane { checkTableModel(returnValue, coverNumber, model, selected, keyColumnNameValueList, newKeyColumnNameValueList); } - private void checkTableModel (int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List keyColumnNameValueList, List newKeyColumnNameValueList) { + private void checkTableModel(int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List keyColumnNameValueList, List newKeyColumnNameValueList) { if (returnValue == 0) { model.removeAllKeyColumnNameValue(); // Richie:全部覆盖,按selected的长度添加默认的行 @@ -538,10 +539,10 @@ public class DBManipulationPane extends BasicBeanPane { model.removeAllKeyColumnNameValue(); // Richie:全部不覆盖,已经存在的就保留,不存在的添加默认行 for (int i = coverNumber; i < selected.length; i++) { - for (int j = 0; j < keyColumnNameValueList.size(); j++) { - if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) { newKeyColumnNameValueList.remove(i); - newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); + newKeyColumnNameValueList.add(i, keyColumnNameValue); } } @@ -552,610 +553,637 @@ public class DBManipulationPane extends BasicBeanPane { } } else if (returnValue == 1 || returnValue == 2) { - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); - } - } else if (returnValue == 5){ - //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); - } - } + for (int i = 0; i < selected.length; i++) { + model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); + } + } else if (returnValue == 5) { + //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 + for (int i = 0; i < selected.length; i++) { + model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); + } + } // Richie:初始化 if (keyColumnNameValueList.isEmpty()) { model.removeAllKeyColumnNameValue(); - for (int i = 0; i < selected.length; i++) { - model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); + for (Object o : selected) { + model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false)); } } - + model.fireTableDataChanged(); keyColumnValuesTable.validate(); } - protected class AddFieldAction extends UpdateAction { - public AddFieldAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); - } + protected class AddFieldAction extends UpdateAction { + public AddFieldAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); + } - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(ActionEvent e) { - KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); + KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); - model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); + model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); updateUpdateCheckBoxEnable(); - model.fireTableDataChanged(); - - keyColumnValuesTable.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); - } - } - - protected class RemoveFieldAction extends UpdateAction { - public RemoveFieldAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); - } - - public void actionPerformed(ActionEvent evt) { - // DBManipulationPane target = this.getDBManipulationPane(); - - int[] selectedRows = keyColumnValuesTable.getSelectedRows(); - if (selectedRows == null || selectedRows.length == 0) { - return; - } - - int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.OK_OPTION) { - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)keyColumnValuesTable.getModel(); - - // 把selectedRows从小到大排个序,先删大的再删小的 - java.util.Arrays.sort(selectedRows); - for (int i = selectedRows.length - 1; i >= 0; i--) { - keyColumnNameValueTableModel.removeKeyColumnNameValue(selectedRows[i]); - } + model.fireTableDataChanged(); + + keyColumnValuesTable.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); + } + } + + protected class RemoveFieldAction extends UpdateAction { + public RemoveFieldAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + // DBManipulationPane target = this.getDBManipulationPane(); + + int[] selectedRows = keyColumnValuesTable.getSelectedRows(); + if (selectedRows == null || selectedRows.length == 0) { + return; + } + + int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.OK_OPTION) { + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) keyColumnValuesTable.getModel(); + + // 把selectedRows从小到大排个序,先删大的再删小的 + java.util.Arrays.sort(selectedRows); + for (int i = selectedRows.length - 1; i >= 0; i--) { + keyColumnNameValueTableModel.removeKeyColumnNameValue(selectedRows[i]); + } updateUpdateCheckBoxEnable(); - keyColumnNameValueTableModel.fireTableDataChanged(); - - // select other one. - if (keyColumnNameValueTableModel.getRowCount() > selectedRows[0]) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(selectedRows[0], selectedRows[0]); - } else if (keyColumnNameValueTableModel.getRowCount() > 0) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - } - } - - /* - * 刷新columnsComboBox - */ - private void refreshColumnsComboBox() { - DefaultComboBoxModel model = (DefaultComboBoxModel)this.columnsComboBox.getModel(); - model.removeAllElements(); - - ColumnName[] columnNames = currentColumnNames(); - for (int i = 0; i < columnNames.length; i++) { - model.addElement(columnNames[i]); - } - } - - // 得到当前的ColumnName[] - private ColumnName[] currentColumnNames() { - // ben:清除原有的 - if (currentColumnNames != null) { - currentColumnNames = null; - } - String[] colNames = this.chooseTable.currentColumnNames(); - int len = colNames.length; - currentColumnNames = new ColumnName[len]; - for (int i = 0; i < len; i++) { - currentColumnNames[i] = new ColumnName(colNames[i]); - } - return currentColumnNames; - } - - /* - * 设置JTable的Column - */ - private void initJTableColumn() { - TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0); - column0.setMaxWidth(50); - - TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1); - column1.setCellRenderer(new ColumnNameTableCellRenderer()); - - TableColumn column2 = this.keyColumnValuesTable.getColumnModel().getColumn(2); - column2.setCellRenderer(new ColumnValueTableCellRenderer()); - - // 设置column1的editor - columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); - columnsComboBox.setRenderer(new UIComboBoxRenderer() { - - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof ColumnName) { - this.setText(((ColumnName)value).name); - } - - return this; - } - - }); - column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { - public boolean stopCellEditing() { - if (super.stopCellEditing()) { - return true; - } - - return false; - } - }); - ((DefaultCellEditor)column1.getCellEditor()).setClickCountToStart(2); - - //设置Column 2的Editor - column2.setCellEditor(new ColumnValueEditor()); - } - - public void populateBean(DBManipulation dbManipulation) { - if (dbManipulation == null) { - dbManipulation = new DBManipulation(); - } + keyColumnNameValueTableModel.fireTableDataChanged(); + + // select other one. + if (keyColumnNameValueTableModel.getRowCount() > selectedRows[0]) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(selectedRows[0], selectedRows[0]); + } else if (keyColumnNameValueTableModel.getRowCount() > 0) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + } + } + + /* + * 刷新columnsComboBox + */ + private void refreshColumnsComboBox() { + DefaultComboBoxModel model = (DefaultComboBoxModel) this.columnsComboBox.getModel(); + model.removeAllElements(); + + ColumnName[] columnNames = currentColumnNames(); + for (ColumnName columnName : columnNames) { + model.addElement(columnName); + } + } + + // 得到当前的ColumnName[] + private ColumnName[] currentColumnNames() { + // ben:清除原有的 + if (currentColumnNames != null) { + currentColumnNames = null; + } + String[] colNames = this.chooseTable.currentColumnNames(); + int len = colNames.length; + currentColumnNames = new ColumnName[len]; + for (int i = 0; i < len; i++) { + currentColumnNames[i] = new ColumnName(colNames[i]); + } + return currentColumnNames; + } + + /* + * 设置JTable的Column + */ + private void initJTableColumn() { + TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0); + column0.setMaxWidth(50); + + TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1); + column1.setCellRenderer(new ColumnNameTableCellRenderer()); + + TableColumn column2 = this.keyColumnValuesTable.getColumnModel().getColumn(2); + column2.setCellRenderer(new ColumnValueTableCellRenderer()); + + // 设置column1的editor + columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); + columnsComboBox.setRenderer(new UIComboBoxRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof ColumnName) { + this.setText(((ColumnName) value).name); + } + + return this; + } + + }); + column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { + @Override + public boolean stopCellEditing() { + return super.stopCellEditing(); + } + }); + ((DefaultCellEditor) column1.getCellEditor()).setClickCountToStart(2); + + //设置Column 2的Editor + column2.setCellEditor(new ColumnValueEditor()); + } + + @Override + public void populateBean(DBManipulation dbManipulation) { + if (dbManipulation == null) { + dbManipulation = new DBManipulation(); + } subMitName = dbManipulation.getName(); - DMLConfig dmlConfig = dbManipulation.getDmlConfig(); - - if (dmlConfig != null) { - if (dmlConfig instanceof IntelliDMLConfig) { - dmlConfigComboBox.setSelectedIndex(0); - } else if (dmlConfig instanceof DeleteConfig) { - dmlConfigComboBox.setSelectedIndex(1); - } else if (dmlConfig instanceof InsertConfig) { - dmlConfigComboBox.setSelectedIndex(2); - } else if (dmlConfig instanceof UpdateConfig) { - dmlConfigComboBox.setSelectedIndex(3); - } else { - dmlConfigComboBox.setSelectedIndex(0); - } - jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; - for (int i = 0; i < jobs.length; i++) { - jobs[i] = dmlConfig.getNameSubmitJob(i); - } - condition = dmlConfig.getCondition(); + DMLConfig dmlConfig = dbManipulation.getDmlConfig(); + + if (dmlConfig != null) { + if (dmlConfig instanceof IntelliDMLConfig) { + dmlConfigComboBox.setSelectedIndex(0); + } else if (dmlConfig instanceof DeleteConfig) { + dmlConfigComboBox.setSelectedIndex(1); + } else if (dmlConfig instanceof InsertConfig) { + dmlConfigComboBox.setSelectedIndex(2); + } else if (dmlConfig instanceof UpdateConfig) { + dmlConfigComboBox.setSelectedIndex(3); + } else { + dmlConfigComboBox.setSelectedIndex(0); + } + jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; + for (int i = 0; i < jobs.length; i++) { + jobs[i] = dmlConfig.getNameSubmitJob(i); + } + condition = dmlConfig.getCondition(); UpdateCheckBox.setSelected(dmlConfig.isUpdateSelected()); - } else { - jobs = null; - condition = null; - dmlConfigComboBox.setSelectedIndex(0); + } else { + jobs = null; + condition = null; + dmlConfigComboBox.setSelectedIndex(0); UpdateCheckBox.setSelected(false); - } + } - String schema = null; - String tableName = null; + String schema = null; + String tableName = null; Table table = null; - if (dmlConfig != null && dmlConfig.getOriTable() != null) { + if (dmlConfig != null && dmlConfig.getOriTable() != null) { table = dmlConfig.getOriTable(); if (table != null) { schema = table.getSchema(); tableName = table.getName(); } } - chooseTable.populateBean(new DataBaseItems(dbManipulation.getDBName(), schema, tableName)); + chooseTable.populateBean(new DataBaseItems(dbManipulation.getDBName(), schema, tableName)); - populateKeyColumnValueTable(dmlConfig); + populateKeyColumnValueTable(dmlConfig); updateUpdateCheckBoxEnable(); - refreshConditionList(); - } - - private void populateKeyColumnValueTable(DMLConfig dmlConfig) { - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); - keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); - - if (dmlConfig != null) { - boolean acceptPara = false; - for (int i = 0; i < v_Types.length; i++) { - if (v_Types[i].accept(new Parameter())) { - acceptPara = true; - break; - } - } - for (int i = 0; i < dmlConfig.getColumnConfigCount(); i++) { - ColumnConfig column = dmlConfig.getColumnConfig(i); - String columnName = column.getColumnName(); - if (!acceptPara && column.getColumnValue() instanceof Parameter) { - // 表单中,将以前的参数转换为公式 - column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter)column.getColumnValue()).getName())); - } - - KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), - column.isSkipUnmodified()); - keyColumnNameValueTableModel.addKeyColumnNameValue(newColumnNameValue); - } - } - keyColumnNameValueTableModel.fireTableDataChanged(); - - // 选择第一个 - if (keyColumnNameValueTableModel.getRowCount() > 0) { - keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - - public DBManipulation updateBean() { - DataBaseItems para = chooseTable.updateBean(true); - DBManipulation dbMani = new DBManipulation(); - dbMani.setName(subMitName); - dbMani.setDBName(para.getDatabaseName()); + refreshConditionList(); + } + + private void populateKeyColumnValueTable(DMLConfig dmlConfig) { + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel(); + keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); + + if (dmlConfig != null) { + boolean acceptPara = false; + for (int i = 0; i < v_Types.length; i++) { + if (v_Types[i].accept(new Parameter())) { + acceptPara = true; + break; + } + } + for (int i = 0; i < dmlConfig.getColumnConfigCount(); i++) { + ColumnConfig column = dmlConfig.getColumnConfig(i); + String columnName = column.getColumnName(); + if (!acceptPara && column.getColumnValue() instanceof Parameter) { + // 表单中,将以前的参数转换为公式 + column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter) column.getColumnValue()).getName())); + } - DMLConfig dmlConfig = new IntelliDMLConfig(); - if (dmlConfigComboBox.getSelectedIndex() == 1) { - dmlConfig = new DeleteConfig(); - } else if (dmlConfigComboBox.getSelectedIndex() == 2) { - dmlConfig = new InsertConfig(); - } else if (dmlConfigComboBox.getSelectedIndex() == 3) { - dmlConfig = new UpdateConfig(); - } + KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), + column.isSkipUnmodified()); + keyColumnNameValueTableModel.addKeyColumnNameValue(newColumnNameValue); + } + } + keyColumnNameValueTableModel.fireTableDataChanged(); + + // 选择第一个 + if (keyColumnNameValueTableModel.getRowCount() > 0) { + keyColumnValuesTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + + @Override + public DBManipulation updateBean() { + DataBaseItems para = chooseTable.updateBean(true); + DBManipulation dbMani = new DBManipulation(); + dbMani.setName(subMitName); + dbMani.setDBName(para.getDatabaseName()); + + DMLConfig dmlConfig = new IntelliDMLConfig(); + if (dmlConfigComboBox.getSelectedIndex() == 1) { + dmlConfig = new DeleteConfig(); + } else if (dmlConfigComboBox.getSelectedIndex() == 2) { + dmlConfig = new InsertConfig(); + } else if (dmlConfigComboBox.getSelectedIndex() == 3) { + dmlConfig = new UpdateConfig(); + } - dbMani.setDmlConfig(dmlConfig); + dbMani.setDmlConfig(dmlConfig); - dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); + dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); - KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); - int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); - for (int i = 0; i < rowCount; i++) { - KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); - // peter:先添加key column name. + KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel(); + int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); + for (int i = 0; i < rowCount; i++) { + KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); + // peter:先添加key column name. - dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey,false)); - } + dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey, false)); + } dmlConfig.setUpdateSelected(UpdateCheckBox.isSelected()); - if (jobs != null) { - for (int i = 0; i < jobs.length; i++) { - dmlConfig.addSubmitJob(jobs[i]); - } - } - dmlConfig.setCondition(condition); - - return dbMani; - } - - protected class ValuePane extends BasicBeanPane { - ValueEditorPane vPane; - - public ValuePane() { - this(v_Types); - } - - public ValuePane(Editor[] types) { - vPane = new ValueEditorPane(types); - this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 45)); - this.add(vPane); - vPane.setPreferredSize(new Dimension(220, 25)); - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); - } - - public void populateBean(Object object) { - vPane.populate(object); - } - - @Override - public Object updateBean() { - return vPane.update(); - } - - } - - /* - * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 - */ - protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { - /** The Swing component being edited. */ - private UILabel textLabel; - private ValuePane vPane; - private BasicDialog vPaneDLG; - - protected ColumnValueEditor() { - this(v_Types); - } - - protected ColumnValueEditor(Editor[] types) { - textLabel = new UILabel(); - textLabel.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - vPaneDLG.setAlwaysOnTop(true); - vPaneDLG.setVisible(true); - - } - }); - - vPane = new ValuePane(types); - vPaneDLG = vPane.showSmallWindow(new JFrame(), new DialogActionAdapter() { - public void doOk() { - fireEditingStopped(); // Make the renderer - // reappear. + if (jobs != null) { + for (NameSubmitJob job : jobs) { + dmlConfig.addSubmitJob(job); + } + } + dmlConfig.setCondition(condition); + + return dbMani; + } + + protected class ValuePane extends BasicBeanPane { + ValueEditorPane vPane; + + public ValuePane() { + this(v_Types); + } + + public ValuePane(Editor[] types) { + vPane = new ValueEditorPane(types); + this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 45)); + this.add(vPane); + vPane.setPreferredSize(new Dimension(220, 25)); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); + } + + @Override + public void populateBean(Object object) { + vPane.populate(object); + } + + @Override + public Object updateBean() { + return vPane.update(); + } + + } + + /* + * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 + */ + protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { + /** + * The Swing component being edited. + */ + private final UILabel textLabel; + private final ValuePane vPane; + + protected ColumnValueEditor() { + this(v_Types); + } + + /** + * 列值编辑器 + * + * @param types 编辑器类型 + */ + protected ColumnValueEditor(Editor[] types) { + textLabel = new UILabel(); + DialogActionAdapter adapter = new DialogActionAdapter() { + @Override + public void doOk() { + fireEditingStopped(); // Make the renderer + // reappear. updateUpdateCheckBoxEnable(); - } - - public void doCancel() { - fireEditingCanceled(); - } - }); - } - - /* - * 双击以编辑 - */ - public boolean isCellEditable(EventObject anEvent) { - if (anEvent instanceof MouseEvent) { - return ((MouseEvent)anEvent).getClickCount() >= 2; - } - return true; - } - - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof ColumnValue) { - vPane.populateBean(((ColumnValue)value).obj); - - if (((ColumnValue)value).obj != null) { - textLabel.setText(((ColumnValue)value).obj.toString()); - } else { - textLabel.setText(""); - } - } - - return textLabel; - } - - public Object getCellEditorValue() { - return new ColumnValue(vPane.updateBean()); - } - } - - public static class ColumnName { - public String name; - - public ColumnName(String name) { - this.name = name; - } - - public boolean equals(Object obj) { - if (!(obj instanceof ColumnName)) { - return false; - } - - return ComparatorUtils.equals(this.name, ((ColumnName)obj).name); - } - - @Override - protected ColumnName clone() throws CloneNotSupportedException { - return new ColumnName(name); - } - } - - public static class ColumnValue { - public Object obj; - - public ColumnValue(Object obj) { - this.obj = obj; - } - - public Object getObj(){ + } + + @Override + public void doCancel() { + fireEditingCanceled(); + } + }; + textLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + Window window = e.getComponent() == null + ? DesignerContext.getDesignerFrame() + : SwingUtilities.getWindowAncestor(e.getComponent()); + vPane.showSmallWindow(window, adapter) + .setVisible(true); + } + }); + vPane = new ValuePane(types); + } + + /* + * 双击以编辑 + */ + @Override + public boolean isCellEditable(EventObject anEvent) { + if (anEvent instanceof MouseEvent) { + return ((MouseEvent) anEvent).getClickCount() >= 2; + } + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof ColumnValue) { + vPane.populateBean(((ColumnValue) value).obj); + + if (((ColumnValue) value).obj != null) { + textLabel.setText(((ColumnValue) value).obj.toString()); + } else { + textLabel.setText(""); + } + } + + return textLabel; + } + + @Override + public Object getCellEditorValue() { + return new ColumnValue(vPane.updateBean()); + } + } + + public static class ColumnName { + public String name; + + public ColumnName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ColumnName)) { + return false; + } + + return ComparatorUtils.equals(this.name, ((ColumnName) obj).name); + } + + @Override + protected ColumnName clone() throws CloneNotSupportedException { + return new ColumnName(name); + } + } + + public static class ColumnValue { + public Object obj; + + public ColumnValue(Object obj) { + this.obj = obj; + } + + public Object getObj() { return obj; } - public boolean equals(Object obj) { - if (!(obj instanceof ColumnValue)) { - return false; - } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ColumnValue)) { + return false; + } - return ComparatorUtils.equals(this.obj, ((ColumnValue)obj).obj); - } + return ComparatorUtils.equals(this.obj, ((ColumnValue) obj).obj); + } - @Override - protected ColumnValue clone() throws CloneNotSupportedException { - return new ColumnValue(obj); - } - } + @Override + protected ColumnValue clone() throws CloneNotSupportedException { + return new ColumnValue(obj); + } + } - protected static class KeyColumnNameValueTable extends JTable { + protected static class KeyColumnNameValueTable extends JTable { - public KeyColumnNameValueTable() { - super(new KeyColumnValueTableModel(null)); - } + public KeyColumnNameValueTable() { + super(new KeyColumnValueTableModel(null)); + } - public KeyColumnTableModel getTableModel4SmartAddCell() { - KeyColumnTableModel clonedTableModel = null; - try { - //智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置 - clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone(); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - return new KeyColumnValueTableModel(clonedTableModel); - } + public KeyColumnTableModel getTableModel4SmartAddCell() { + KeyColumnTableModel clonedTableModel = null; + try { + //智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置 + clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone(); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return new KeyColumnValueTableModel(clonedTableModel); + } - } + } - protected abstract static class KeyColumnTableModel extends AbstractTableModel { + protected abstract static class KeyColumnTableModel extends AbstractTableModel { public static final String RAW_KEY = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_RWA_Key"); public static final String COLUMN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Column"); - public static final String VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"); - - public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; - - protected List keyColumnNameValueList = new ArrayList<>(); - - public KeyColumnTableModel(KeyColumnTableModel model) { - if (model != null) { - this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); - } - } - - public String getColumnName(int col) { - return COLUMN_NAMES[col]; - } - - public int getColumnCount() { - return COLUMN_NAMES.length; - } - - public int getRowCount() { - return keyColumnNameValueList.size(); - } - - public void addKeyColumnNameValue(KeyColumnNameValue keyColumnNameValue) { - this.keyColumnNameValueList.add(keyColumnNameValue); - } - - public void removeKeyColumnNameValue(int index) { - this.keyColumnNameValueList.remove(index); - } - - public KeyColumnNameValue getKeyColumnNameValue(int index) { - return this.keyColumnNameValueList.get(index); - } - - public void removeAllKeyColumnNameValue() { - this.keyColumnNameValueList.clear(); - } - - public void refreshNameValueList(KeyColumnTableModel model) { - if (model != null) { - this.keyColumnNameValueList.clear(); - this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); - } - } - } - - protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable{ - - public KeyColumnValueTableModel(KeyColumnTableModel model) { - super(model); - } - - public Object getValueAt(int row, int col) { - KeyColumnNameValue knv = keyColumnNameValueList.get(row); - - switch (col) { - case 0: - return knv.isKey; - case 1: - return knv.cn; - case 2: - return knv.cv; - } - return null; - } - - public void setValueAt(Object value, int row, int col) { - KeyColumnNameValue knv = keyColumnNameValueList.get(row); - - if (col == 0 && value instanceof Boolean) { - knv.isKey = ((Boolean)value).booleanValue(); - } else if (col == 1 && value instanceof ColumnName) { - knv.cn = (ColumnName)value; - } else if (col == 2 && value instanceof ColumnValue) { - knv.cv = (ColumnValue)value; - } - } - - public Class getColumnClass(int c) { - switch (c) { - case 0: - return Boolean.class; - case 1: - return ColumnName.class; - case 2: - return ColumnValue.class; - } - return String.class; - } - - public boolean isCellEditable(int row, int col) { - return true; - } - - @Override - protected KeyColumnValueTableModel clone() throws CloneNotSupportedException { - KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone(); - cloned.keyColumnNameValueList = new ArrayList<>(); - for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { - cloned.keyColumnNameValueList.add(keyColumnNameValue.clone()); - } - return cloned; - } - } - - - - public static class KeyColumnNameValue { - private boolean isKey = false; - private ColumnName cn; - public ColumnValue cv; - - public KeyColumnNameValue(boolean isKey, ColumnName cn, ColumnValue cv, boolean skip) { - this.isKey = isKey; - this.cn = cn; - this.cv = cv; - } - - /** - * 字符串 - * - * @return 字符串z - */ - public String toString() { - return (isKey ? "* " : "") + cn + ":" + cv; - } - - @Override - protected KeyColumnNameValue clone() throws CloneNotSupportedException { - return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false); - } - } - - /* - * ColumnNameTableCellRenderer - */ - public class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - if (value instanceof ColumnName) { - this.setText(((ColumnName)value).name); - } - - return this; - } - } - - /* - * ColumnValueTableCellRenderer - */ - private class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - if (value instanceof ColumnValue) { - if (((ColumnValue)value).obj != null) { - if (((ColumnValue)value).obj instanceof Date) { - this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue)value).obj)); - } else { - this.setText(((ColumnValue)value).obj.toString()); - } - } else { - this.setText(""); - } - } - - return this; - } - } + public static final String VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Value"); + + public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; + + protected List keyColumnNameValueList = new ArrayList<>(); + + public KeyColumnTableModel(KeyColumnTableModel model) { + if (model != null) { + this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); + } + } + + @Override + public String getColumnName(int col) { + return COLUMN_NAMES[col]; + } + + @Override + public int getColumnCount() { + return COLUMN_NAMES.length; + } + + @Override + public int getRowCount() { + return keyColumnNameValueList.size(); + } + + public void addKeyColumnNameValue(KeyColumnNameValue keyColumnNameValue) { + this.keyColumnNameValueList.add(keyColumnNameValue); + } + + public void removeKeyColumnNameValue(int index) { + this.keyColumnNameValueList.remove(index); + } + + public KeyColumnNameValue getKeyColumnNameValue(int index) { + return this.keyColumnNameValueList.get(index); + } + + public void removeAllKeyColumnNameValue() { + this.keyColumnNameValueList.clear(); + } + + public void refreshNameValueList(KeyColumnTableModel model) { + if (model != null) { + this.keyColumnNameValueList.clear(); + this.keyColumnNameValueList.addAll(model.keyColumnNameValueList); + } + } + } + + protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable { + + public KeyColumnValueTableModel(KeyColumnTableModel model) { + super(model); + } + + @Override + public Object getValueAt(int row, int col) { + KeyColumnNameValue knv = keyColumnNameValueList.get(row); + + switch (col) { + case 0: + return knv.isKey; + case 1: + return knv.cn; + case 2: + return knv.cv; + } + return null; + } + + @Override + public void setValueAt(Object value, int row, int col) { + KeyColumnNameValue knv = keyColumnNameValueList.get(row); + + if (col == 0 && value instanceof Boolean) { + knv.isKey = ((Boolean) value).booleanValue(); + } else if (col == 1 && value instanceof ColumnName) { + knv.cn = (ColumnName) value; + } else if (col == 2 && value instanceof ColumnValue) { + knv.cv = (ColumnValue) value; + } + } + + @Override + public Class getColumnClass(int c) { + switch (c) { + case 0: + return Boolean.class; + case 1: + return ColumnName.class; + case 2: + return ColumnValue.class; + } + return String.class; + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + protected KeyColumnValueTableModel clone() throws CloneNotSupportedException { + KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone(); + cloned.keyColumnNameValueList = new ArrayList<>(); + for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) { + cloned.keyColumnNameValueList.add(keyColumnNameValue.clone()); + } + return cloned; + } + } + + + public static class KeyColumnNameValue { + private boolean isKey = false; + private ColumnName cn; + public ColumnValue cv; + + public KeyColumnNameValue(boolean isKey, ColumnName cn, ColumnValue cv, boolean skip) { + this.isKey = isKey; + this.cn = cn; + this.cv = cv; + } + + /** + * 字符串 + * + * @return 字符串z + */ + @Override + public String toString() { + return (isKey ? "* " : "") + cn + ":" + cv; + } + + @Override + protected KeyColumnNameValue clone() throws CloneNotSupportedException { + return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false); + } + } + + /* + * ColumnNameTableCellRenderer + */ + public static class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnName) { + this.setText(((ColumnName) value).name); + } + + return this; + } + } + + /* + * ColumnValueTableCellRenderer + */ + private static class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value instanceof ColumnValue) { + if (((ColumnValue) value).obj != null) { + if (((ColumnValue) value).obj instanceof Date) { + this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue) value).obj)); + } else { + this.setText(((ColumnValue) value).obj.toString()); + } + } else { + this.setText(""); + } + } + + return this; + } + } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java index 1102f7a64..8c62d6e72 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java @@ -14,7 +14,7 @@ import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; -import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; +import com.fr.van.chart.map.designer.type.MapStatusPane; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -154,7 +154,7 @@ public class DrillMapLayerPane extends BasicBeanPane { rowSize[i + 1] = p; int d = i + 1; UILabel label = new UILabel(String.format("%s%d%s", Toolkit.i18nText("Fine-Design_Chart_Index_Article"), d, Toolkit.i18nText("Fine-Design_Chart_Index_Layer"))); - UIComboBox level = new UIComboBox(VanChartMapSourceChoosePane.ZOOM_LEVELS); + UIComboBox level = new UIComboBox(MapStatusPane.ZOOM_LEVELS); level.setEnabled(i != 0); UIComboBox type = new UIComboBox(items); detailComps[i + 1] = new Component[]{label, level, type}; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index 46126d277..ab46f5526 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -35,6 +35,7 @@ import com.fr.van.chart.designer.style.VanChartRangeLegendPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.VanLegendPaneWidthOutHighlight; import com.fr.van.chart.designer.style.label.VanChartGaugePlotLabelPane; +import com.fr.van.chart.designer.style.label.VanChartPiePlotLabelPane; import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotRefreshTooltipPane; @@ -209,6 +210,8 @@ public class PlotFactory { public static VanChartPlotLabelPane createPlotLabelPane(Plot plot, VanChartStylePane stylePane, boolean inCondition) { if (plot instanceof VanChartGaugePlot) { return new VanChartGaugePlotLabelPane(plot, stylePane); + } else if (plot instanceof PiePlot4VanChart) { + return new VanChartPiePlotLabelPane(plot, stylePane, inCondition); } return new VanChartPlotLabelPane(plot, stylePane, inCondition); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithShapePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithShapePane.java index f764c9baa..f40a51f12 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithShapePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithShapePane.java @@ -46,6 +46,10 @@ public class VanChartBorderWithShapePane extends BasicPane { createBorderPane(); } + public LineComboBox getLineTypeBox() { + return lineTypeBox; + } + private void initComponents() { lineTypeBox = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); lineColorButton = new UIButtonGroup<>(new String[]{ @@ -106,7 +110,7 @@ public class VanChartBorderWithShapePane extends BasicPane { borderRadius.setEnabled(borderShape.getSelectedIndex() == RECTANGULAR_INDEX || borderShape.getSelectedIndex() == DIALOG_INDEX); } - private JPanel createLineTypePane() { + protected JPanel createLineTypePane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithCheckBox.java new file mode 100644 index 000000000..8d088827f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithCheckBox.java @@ -0,0 +1,23 @@ +package com.fr.van.chart.designer.component.format; + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-10 + */ +public class SummaryValueFormatPaneWithCheckBox extends VanChartFormatPaneWithCheckBox { + + public SummaryValueFormatPaneWithCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + @Override + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Use_Summary_Value"); + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithoutCheckBox.java new file mode 100644 index 000000000..400af6b7f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/SummaryValueFormatPaneWithoutCheckBox.java @@ -0,0 +1,23 @@ +package com.fr.van.chart.designer.component.format; + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-10 + */ +public class SummaryValueFormatPaneWithoutCheckBox extends VanChartFormatPaneWithoutCheckBox { + + public SummaryValueFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Use_Summary_Value"); + } +} + diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java new file mode 100644 index 000000000..4c28c78b0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieCategoryLabelDetailPane.java @@ -0,0 +1,64 @@ +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.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.stable.Constants; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.pie.style.VanChartPieCategoryLabelContentPane; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-09 + */ +public class VanChartPieCategoryLabelDetailPane extends VanChartPlotLabelDetailPane { + + public VanChartPieCategoryLabelDetailPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + super(plot, parent, inCondition); + } + + protected void initToolTipContentPane(Plot plot) { + setDataLabelContentPane(new VanChartPieCategoryLabelContentPane(getParentPane(), this, isInCondition())); + } + + protected JPanel createLabelPositionPane(String title, Plot plot) { + String[] positionName = new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom"), + Toolkit.i18nText("Fine-Design_Form_Center"), + Toolkit.i18nText("Fine-Design_Chart_Axis_Top") + }; + + Integer[] positionValue = new Integer[]{Constants.BOTTOM, Constants.CENTER, Constants.TOP}; + + UIButtonGroup position = new UIButtonGroup<>(positionName, positionValue); + setPosition(position); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = {p, p}; + double[] col = {f, e}; + + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), position}, + }; + + return TableLayoutHelper.createTableLayoutPane(components, row, col); + } + + protected void checkPositionPane(String title) { + + } + + protected JPanel createBorderAndBackgroundPane() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java new file mode 100644 index 000000000..ac24b9951 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java @@ -0,0 +1,61 @@ +package com.fr.van.chart.designer.style.label; + +import com.fr.chart.chartattr.Plot; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.base.AttrLabelDetail; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-09 + */ +public class VanChartPiePlotLabelPane extends VanChartPlotLabelPane { + + private VanChartPlotLabelDetailPane pieCategoryLabelPane; + + public VanChartPiePlotLabelPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + super(plot, parent, inCondition); + } + + protected void createLabelPane() { + setLabelPane(new JPanel(new BorderLayout(0, 4))); + setLabelDetailPane(new VanChartPieValueLabelDetailPane(getPlot(), getParentPane(), isInCondition())); + JPanel valuePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Label"), getLabelDetailPane()); + getLabelPane().add(valuePane, BorderLayout.NORTH); + + if (!isInCondition()) { + pieCategoryLabelPane = new VanChartPieCategoryLabelDetailPane(getPlot(), getParentPane(), isInCondition()); + JPanel categoryPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Category_Label"), pieCategoryLabelPane); + getLabelPane().add(categoryPane, BorderLayout.CENTER); + } + } + + public void populate(AttrLabel attrLabel) { + if (attrLabel == null) { + attrLabel = ((VanChartPlot) this.getPlot()).getDefaultAttrLabel(); + } + super.populate(attrLabel); + if (pieCategoryLabelPane != null) { + AttrLabelDetail labelDetail = attrLabel.getSecondLabelDetail(); + pieCategoryLabelPane.populate(labelDetail); + } + } + + public AttrLabel update() { + AttrLabel attrLabel = super.update(); + if (pieCategoryLabelPane != null) { + AttrLabelDetail labelDetail = attrLabel.getSecondLabelDetail(); + pieCategoryLabelPane.update(labelDetail); + } else { + attrLabel.setSecondLabelDetail(null); + } + return attrLabel; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieValueLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieValueLabelDetailPane.java new file mode 100644 index 000000000..707f6f5fd --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPieValueLabelDetailPane.java @@ -0,0 +1,72 @@ +package com.fr.van.chart.designer.style.label; + +import com.fr.chart.chartattr.Plot; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; +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 com.fr.van.chart.pie.style.VanChartPieValueLabelContentPane; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-09 + */ +public class VanChartPieValueLabelDetailPane extends VanChartPlotLabelDetailPane { + + public VanChartPieValueLabelDetailPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + super(plot, parent, inCondition); + } + + protected void initToolTipContentPane(Plot plot) { + setDataLabelContentPane(new VanChartPieValueLabelContentPane(getParentPane(), this, isInCondition())); + } + + protected JPanel getLabelLayoutPane(JPanel panel, String title) { + return panel; + } + + protected JPanel createLabelBorderPane() { + VanChartBorderWithShapePane borderPane = new VanChartBorderWithShapePane() { + @Override + protected JPanel createLineTypePane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + double[] columnSize = {f, e}; + double[] rowSize = {p}; + + Component[][] components = new Component[][]{ + new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Border")), + UIComponentUtils.wrapWithBorderLayoutPane(getLineTypeBox())}}; + + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + } + }; + setBorderPane(borderPane); + return borderPane; + } + + protected JPanel createLabelBackgroundPane() { + VanChartBackgroundWithOutImagePane backgroundPane = new VanChartBackgroundWithOutImagePane() { + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Utils_Background")), typeComboBox}, + new Component[]{null, centerPane}, + new Component[]{getTransparentLabel(), transparent}, + }; + } + }; + setBackgroundPane(backgroundPane); + return backgroundPane; + } +} 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 5a8af100d..20ce7452b 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 @@ -83,6 +83,19 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return parent; } + public void setPosition(UIButtonGroup position) { + this.position = position; + } + + public void setBorderPane(VanChartBorderWithShapePane borderPane) { + this.borderPane = borderPane; + } + + public void setBackgroundPane(VanChartBackgroundWithOutImagePane backgroundPane) { + this.backgroundPane = backgroundPane; + } + + protected void initLabelDetailPane(Plot plot) { this.setLayout(new BorderLayout()); initToolTipContentPane(plot); @@ -122,8 +135,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { 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} + new Component[]{createBorderAndBackgroundPane(), null}, }; } @@ -138,6 +150,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { }; } + protected JPanel createBorderAndBackgroundPane() { + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 5)); + jPanel.add(createLabelBorderPane(), BorderLayout.NORTH); + jPanel.add(createLabelBackgroundPane(), BorderLayout.CENTER); + return jPanel; + } + private JPanel createLabelBorderPane() { borderPane = new VanChartBorderWithShapePane(); borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); 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 71ad599fd..4aed8c30a 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 @@ -44,6 +44,10 @@ public class VanChartPlotLabelPane extends BasicPane { addComponents(); } + public boolean isInCondition() { + return inCondition; + } + public VanChartPlotLabelDetailPane getLabelDetailPane() { return labelDetailPane; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java index 0c6fcc1e4..749755991 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java @@ -14,7 +14,7 @@ import com.fr.plugin.chart.map.server.CompatibleGeoJSONTreeHelper; import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; +import com.fr.van.chart.map.designer.type.MapStatusPane; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -105,7 +105,7 @@ public class DrillMapLayerPane extends BasicScrollPane { rowSize[i + 1] = p; int d = i + 1; UILabel label = new UILabel(String.format("%s%d%s", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Index_Article"), d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Index_Layer"))); - UIComboBox level = new UIComboBox(VanChartMapSourceChoosePane.ZOOM_LEVELS); + UIComboBox level = new UIComboBox(MapStatusPane.ZOOM_LEVELS); level.setEnabled(i != 0); UIComboBox type = new UIComboBox(TEMP.get(oldMapType)); detailComps[i + 1] = new Component[]{label, level, type}; diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java index c4a803134..48f8b2434 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java @@ -8,11 +8,14 @@ import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.drillmap.DrillMapIndependentVanChart; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; import com.fr.plugin.chart.drillmap.data.DrillMapDefinition; +import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; +import com.fr.van.chart.map.designer.type.GeoUrlPane; import com.fr.van.chart.map.designer.type.VanChartMapPlotPane; import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; +import javax.swing.tree.TreeNode; import java.util.ArrayList; /** @@ -30,10 +33,15 @@ public class VanChartDrillMapPlotPane extends VanChartMapPlotPane { @Override protected VanChartMapSourceChoosePane createSourceChoosePane() { - return new VanChartMapSourceChoosePane(){ + return new VanChartMapSourceChoosePane() { @Override - protected boolean supportParam(){ - return false; + protected void initGeoUrlPane() { + setGeoUrlPane(new GeoUrlPane() { + @Override + protected TreeNode getRootNode() { + return GEOJSONTreeHelper.getInstance().getRootNodeWithoutPara(); + } + }); } }; } @@ -59,7 +67,7 @@ public class VanChartDrillMapPlotPane extends VanChartMapPlotPane { protected void resetAttr(Plot plot) { super.resetAttr(plot); - if(plot instanceof VanChartDrillMapPlot) { + if (plot instanceof VanChartDrillMapPlot) { resetLayerTypeAndZoomLevel((VanChartDrillMapPlot) plot); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapSourceChoosePane.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapSourceChoosePane.java deleted file mode 100644 index 3eaec5f59..000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapSourceChoosePane.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fr.van.chart.heatmap.designer.type; - -import com.fr.design.gui.ilable.UILabel; - -import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; - -/** - * Created by Mitisky on 16/10/20. - */ -public class VanChartHeatMapSourceChoosePane extends VanChartMapSourceChoosePane { - @Override - protected UILabel createSourceTitleLabel() { - return new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java index 8f4a72de2..32529591e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java @@ -3,6 +3,8 @@ package com.fr.van.chart.heatmap.designer.type; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; @@ -11,6 +13,7 @@ import com.fr.plugin.chart.heatmap.HeatMapIndependentVanChart; import com.fr.plugin.chart.heatmap.VanChartHeatMapPlot; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.van.chart.map.designer.type.GeoUrlPane; import com.fr.van.chart.map.designer.type.VanChartMapPlotPane; import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; @@ -27,18 +30,27 @@ public class VanChartHeatMapTypePane extends VanChartMapPlotPane { @Override protected VanChartMapSourceChoosePane createSourceChoosePane() { - return new VanChartHeatMapSourceChoosePane(); + return new VanChartMapSourceChoosePane() { + @Override + protected void initGeoUrlPane() { + setGeoUrlPane(new GeoUrlPane() { + @Override + protected UILabel createSourceTitleLabel() { + return new UILabel(Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); + } + }); + } + }; } //适用一种图表只有一种类型的 public void populateBean(VanChart chart) { typeDemo.get(0).isPressing = true; - VanChartHeatMapPlot plot = (VanChartHeatMapPlot)chart.getPlot(); + VanChartHeatMapPlot plot = (VanChartHeatMapPlot) chart.getPlot(); populateSourcePane(plot); boolean enabled = !CompatibleGEOJSONHelper.isDeprecated(plot.getGeoUrl()); GUICoreUtils.setEnabled(this.getTypePane(), enabled); - GUICoreUtils.setEnabled(this.getSourceChoosePane().getSourceComboBox(), enabled); checkDemosBackground(); } @@ -53,13 +65,13 @@ public class VanChartHeatMapTypePane extends VanChartMapPlotPane { return tools; } - protected Plot getSelectedClonedPlot(){ + protected Plot getSelectedClonedPlot() { Chart chart = getDefaultChart(); - VanChartHeatMapPlot newPlot = (VanChartHeatMapPlot)chart.getPlot(); + VanChartHeatMapPlot newPlot = (VanChartHeatMapPlot) chart.getPlot(); Plot cloned = null; try { - cloned = (Plot)newPlot.clone(); + cloned = (Plot) newPlot.clone(); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GeoUrlPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GeoUrlPane.java new file mode 100644 index 000000000..c69297fa8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GeoUrlPane.java @@ -0,0 +1,258 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.base.Parameter; +import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelper; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.FRTreeComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; +import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; +import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; +import com.fr.plugin.chart.type.MapType; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; +import com.fr.workspace.WorkContext; + +import javax.swing.JPanel; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class GeoUrlPane extends JPanel implements UIObserver { + + private UILabel sourceTitleLabel; + private FRTreeComboBox sourceComboBox; + private MapDataTree mapDataTree; + private TreePath selectTreePath; + + private UIObserverListener listener; + + private String[] oldParams; + + public GeoUrlPane() { + initComps(); + } + + private void initComps() { + this.setLayout(new BorderLayout()); + this.add(createMapSourcesPane(), BorderLayout.CENTER); + } + + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + private JPanel createMapSourcesPane() { + + mapDataTree = new MapDataTree(this.getRootNode()); + mapDataTree.setEditable(false); + mapDataTree.selectDefaultTreeNode(); + sourceComboBox = new FRTreeComboBox(mapDataTree, mapDataTree.getCellRenderer()) { + //搜索 + protected void dealSamePath(TreePath parent, TreeNode node, UITextField textField) { + String searchText = textField.getText(); + GeoUrlPane.this.mapDataTree.search(searchText); + } + + //选中 tree---combobox + public void setSelectedItem(Object o) { + TreePath oldPath = mapDataTree.getSelectionPath(); + Object oldText = getSelectedItem(); + if (o != null && o instanceof TreePath) { + selectTreePath = (TreePath) o; + this.tree.setSelectionPath(selectTreePath); + this.getModel().setSelectedItem(pathToString(selectTreePath)); + if (ComparatorUtils.equals(oldText, getSelectedItem()) && !ComparatorUtils.equals(oldPath, selectTreePath)) { + //point的江苏省切换到area的江苏省 + listener.doChange(); + } + } else if (o instanceof String) {//list里面没有 + selectTreePath = null; + this.tree.setSelectionPath(null); + this.getModel().setSelectedItem(ChartGEOJSONHelper.getPresentNameWithPath((String) o)); + } + } + + @Override + protected String pathToString(TreePath path) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); + //不显示后缀 + return ChartGEOJSONHelper.getPresentNameWithPath(node.toString()); + } + + @Override + protected boolean customSelectable(DefaultMutableTreeNode node) { + return GEOJSONTreeHelper.isSelectableTreeNode(node); + } + }; + sourceComboBox.setEditable(true); + sourceComboBox.setOnlyLeafSelectable(false); + sourceComboBox.addPopupMenuListener(popupMenuListener); + sourceTitleLabel = createSourceTitleLabel(); + + + boolean hasRefreshButton = !WorkContext.getCurrent().isLocal(); + UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/images/control/refresh.png")); + button.setToolTipText(Toolkit.i18nText("Fine-Design_Chart_Update_Remote_Map_JSON")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + GEOJSONHelper.reset(); + GEOJSONHelper.getInstance(); + } + }); + + double p = TableLayout.PREFERRED; + double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double f = TableLayout.FILL; + double[] rowSize = {p, p}; + double[] columnSize = hasRefreshButton ? new double[]{d + 10, e - 20, 20} : new double[]{f, e}; + + Component[] comps = hasRefreshButton + ? new Component[]{sourceTitleLabel, sourceComboBox, button} + : new Component[]{sourceTitleLabel, sourceComboBox}; + + double hGap = hasRefreshButton ? 0 : TableLayout4VanChartHelper.COMPONENT_INTERVAL; + Component[][] components = new Component[][]{ + new Component[]{null, null}, + comps, + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, hGap, LayoutConstants.VGAP_LARGE); + } + + protected UILabel createSourceTitleLabel() { + return new UILabel(Toolkit.i18nText("Fine-Design_Chart_Map_Area")); + } + + protected TreeNode getRootNode() { + return GEOJSONTreeHelper.getInstance().getRootNodeWithPara(); + } + + private String[] getParamsName() { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + + if (jTemplate == null) { + return new String[0]; + } + + Parameter[] parameters = jTemplate.getJTemplateParameters(); + + int len = parameters.length; + String[] names = new String[len]; + + for (int i = 0; i < len; i++) { + names[i] = parameters[i].getName(); + } + + return names; + } + + private PopupMenuListener popupMenuListener = new PopupMenuListener() { + public void popupMenuCanceled(PopupMenuEvent e) { + } + + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + } + + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + + GEOJSONTreeHelper.reset(); + mapDataTree.changeRootNode(GeoUrlPane.this.getRootNode()); + GEOJSONTreeHelper.getInstance().updateParamRootNode(GeoUrlPane.this.getParamsName()); + + if (selectTreePath != null) { + mapDataTree.setSelectNodePath(CompatibleGEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString())); + selectTreePath = mapDataTree.getSelectionPath(); + } + + mapDataTree.updateUI();//因为服务器那边可能随时编辑,所以这边要重画 + mapDataTree.setSelectionPath(selectTreePath); + mapDataTree.scrollPathToVisible(selectTreePath); + } + }; + + public void populate(VanChartMapPlot mapPlot) { + resetComponentValue(mapPlot, false); + String geoUrl = mapPlot.getGeoUrl(); + mapDataTree.setSelectNodePath(geoUrl); + selectTreePath = mapDataTree.getSelectionPath(); + + if (selectTreePath == null) {//此url当前环境没有 + sourceComboBox.setSelectedItem(geoUrl); + } else { + sourceComboBox.setSelectedItem(selectTreePath); + } + boolean enabled = !CompatibleGEOJSONHelper.isDeprecated(mapPlot.getGeoUrl()); + GUICoreUtils.setEnabled(sourceComboBox, enabled); + } + + public String update() { + return mapDataTree.getSelectNodeJSONPath(); + } + + protected void resetComponentValue(VanChartMapPlot mapPlot, boolean samePlotChange) { + MapType mapType = mapPlot.getMapType(); + + //获取最新的参数 + String[] params = getParamsName(); + + if (!ComparatorUtils.equals(oldParams, params)) { + oldParams = params; + GEOJSONTreeHelper.getInstance().updateParamRootNode(params); + } + + mapDataTree.changeRootNode(this.getRootNode()); + if (samePlotChange) { + String nodePath = ChartGEOJSONHelper.getDefaultJSONURL(); + mapPlot.setGeoUrl(nodePath); + mapDataTree.setSelectNodePath(nodePath); + selectTreePath = mapDataTree.getSelectionPath(); + sourceComboBox.setSelectedItem(selectTreePath); + } + switch (mapType) { + case CUSTOM: + sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); + break; + case POINT: + sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Point")); + break; + case LINE: + sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Point")); + break; + default: + sourceTitleLabel.setText(Toolkit.i18nText("Fine-Design_Chart_Map_Area")); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java new file mode 100644 index 000000000..406b89610 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java @@ -0,0 +1,303 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.base.Utils; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.base.GisLayer; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.map.server.MapLayerConfigManager; +import com.fr.plugin.chart.type.GISLayerType; +import com.fr.plugin.chart.type.GaoDeGisType; +import com.fr.plugin.chart.type.ZoomLevel; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JPanel; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ItemEvent; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class GisLayerPane extends JPanel implements UIObserver { + + private UIButtonGroup gisButton; + private JPanel layerPaneCheckPane; + private UIComboBox gisGaoDeLayer; + private UIComboBox gisLayer; + private JPanel layerCardPane; + + private WMSLayerPane wmsLayerPane; + private TileLayerPane tileLayerPane; + + private UIComboBox zoomLevel; + + private String[] layers = MapLayerConfigManager.getLayerItems(); + + public GisLayerPane() { + initComps(); + } + + private void initComps() { + this.setLayout(new BorderLayout()); + this.add(createGISLayerPane(), BorderLayout.CENTER); + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.wmsLayerPane.registerChangeListener(listener); + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + public void registerZoomLevel(UIComboBox zoomLevel) { + this.zoomLevel = zoomLevel; + } + + private boolean isStandardGis() { + return gisButton.getSelectedIndex() == 0; + } + + + private JPanel createGISLayerPane() { + gisButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); + gisGaoDeLayer = new UIComboBox(MapLayerConfigManager.getGaoDeLayerItems()); + gisButton.addActionListener(event -> { + refreshZoomLevel(); + checkLayerCardPane(); + }); + + gisGaoDeLayer.addItemListener(event -> refreshZoomLevel()); + + initCustomGISLayerPane(); + initLayerCardPane(); + + layerPaneCheckPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (isStandardGis()) { + return gisGaoDeLayer.getPreferredSize(); + } else { + return gisLayer.getPreferredSize(); + } + } + }; + layerPaneCheckPane.add(gisGaoDeLayer, "standard"); + layerPaneCheckPane.add(gisLayer, "custom"); + + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = {p, p, p}; + double[] col = {f, e}; + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gis_Layer")), gisButton}, + new Component[]{null, layerPaneCheckPane}, + new Component[]{layerCardPane, null}, + }; + + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); + panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + return panel; + } + + private void initLayerCardPane() { + tileLayerPane = new TileLayerPane(); + wmsLayerPane = new WMSLayerPane(); + + layerCardPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (isStandardGis()) { + return new Dimension(0, 0); + } + String itemName = Utils.objectToString(gisLayer.getSelectedItem()); + if (MapLayerConfigManager.isCustomLayer(itemName)) { + return tileLayerPane.getPreferredSize(); + } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { + return wmsLayerPane.getPreferredSize(); + } + return new Dimension(0, 0); + } + }; + + for (String itemName : layers) { + JPanel pane = new JPanel(); + if (MapLayerConfigManager.isCustomLayer(itemName)) { + pane = tileLayerPane; + } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { + pane = wmsLayerPane; + } + layerCardPane.add(pane, itemName); + } + } + + private void initCustomGISLayerPane() { + gisLayer = new UIComboBox(layers); + + gisLayer.addItemListener(e -> + { + if (e.getStateChange() == ItemEvent.SELECTED) { + checkCustomLayerCardPane(); + } + refreshZoomLevel(); + } + ); + + gisLayer.addPopupMenuListener(new PopupMenuListener() { + public void popupMenuCanceled(PopupMenuEvent e) { + } + + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + } + + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + + String selected = Utils.objectToString(gisLayer.getSelectedItem()); + ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem(); + + gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems())); + + gisLayer.setSelectedItem(selected); + zoomLevel.setSelectedItem(zoomSelected); + } + }); + } + + private void refreshZoomLevel() { + //gis图层不同,对应的缩放等级不同。 + ZoomLevel[] levels; + if (isStandardGis()) { + if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { + levels = MapStatusPane.ZOOM_LEVELS; + } else { + levels = MapStatusPane.GAODE_ZOOM_LEVELS; + } + } else { + if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { + levels = MapStatusPane.BLUE_ZOOM_LEVELS; + } else if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { + levels = MapStatusPane.GAODE_ZOOM_LEVELS; + } else { + levels = MapStatusPane.ZOOM_LEVELS; + } + } + zoomLevel.setModel(new DefaultComboBoxModel(levels)); + } + + + private void checkLayerCardPane() { + CardLayout cardLayout = (CardLayout) layerPaneCheckPane.getLayout(); + cardLayout.show(layerPaneCheckPane, isStandardGis() ? "standard" : "custom"); + } + + private void checkCustomLayerCardPane() { + CardLayout cardLayout = (CardLayout) layerCardPane.getLayout(); + cardLayout.show(layerCardPane, Utils.objectToString(gisLayer.getSelectedItem())); + } + + public void resetGisLayer(VanChartMapPlot mapPlot) { + //TODO Bjorn 地图gis图层自动逻辑 + /* mapPlot.getGisLayer().setGisLayerType(GISLayerType.AUTO); + mapPlot.getGisLayer().setLayerName(GISLayerType.getLocString(GISLayerType.AUTO));*/ + + GaoDeGisType gaoDeGisType= mapPlot.getDefaultGisLayerType(); + + mapPlot.getGisLayer().setGisLayerType(GISLayerType.GAO_DE_API); + mapPlot.getGisLayer().setLayerName(gaoDeGisType.getTypeName()); + mapPlot.getGisLayer().setGaoDeGisType(gaoDeGisType); + populate(mapPlot.getGisLayer()); + } + + public void populate(GisLayer layer) { + switch (layer.getGisLayerType()) { + case GAO_DE_API: + case LAYER_NULL: + populateStandardGis(layer); + break; + default: + populateCustomGis(layer); + } + refreshZoomLevel(); + + checkCustomLayerCardPane(); + checkLayerCardPane(); + } + + private void populateStandardGis(GisLayer layer) { + gisButton.setSelectedIndex(0); + if (layer.getGisLayerType() == GISLayerType.LAYER_NULL) { + gisGaoDeLayer.setSelectedIndex(gisGaoDeLayer.getItemCount() - 1); + } else { + gisGaoDeLayer.setSelectedItem(layer.getGaoDeGisType().getTypeName()); + } + } + + private void populateCustomGis(GisLayer layer) { + gisButton.setSelectedIndex(1); + gisLayer.setSelectedItem(layer.getShowItemName()); + + switch (layer.getGisLayerType()) { + case CUSTOM_WMS_LAYER: + wmsLayerPane.populate(layer); + break; + case CUSTOM_TILE_LAYER: + tileLayerPane.populate(layer); + break; + } + } + + public void update(GisLayer layer) { + if (isStandardGis()) { + updateStandardGis(layer); + } else { + updateCustomGis(layer); + } + } + + private void updateStandardGis(GisLayer layer) { + String layerName = Utils.objectToString(gisGaoDeLayer.getSelectedItem()); + layer.setLayerName(layerName); + if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { + layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); + } else { + layer.setGisLayerType(GISLayerType.GAO_DE_API); + layer.setGaoDeGisType(GaoDeGisType.parseByLocaleName(layerName)); + } + } + + private void updateCustomGis(GisLayer layer) { + String layerName = Utils.objectToString(gisLayer.getSelectedItem()); + layer.setLayerName(layerName); + layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); + + switch (layer.getGisLayerType()) { + case CUSTOM_WMS_LAYER: + wmsLayerPane.update(layer); + break; + case CUSTOM_TILE_LAYER: + tileLayerPane.update(layer); + break; + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/MapStatusPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/MapStatusPane.java new file mode 100644 index 000000000..668a9b774 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/MapStatusPane.java @@ -0,0 +1,167 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.plugin.chart.base.ViewCenter; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.type.ZoomLevel; +import com.fr.stable.ArrayUtils; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class MapStatusPane extends JPanel { + + public static final ZoomLevel[] ZOOM_LEVELS = new ZoomLevel[]{ + ZoomLevel.AUTO, + ZoomLevel.ZERO, ZoomLevel.ZEROPOINTFIVE, + ZoomLevel.ONE, ZoomLevel.ONEPOINTFIVE, + ZoomLevel.TWO, ZoomLevel.TWOPOINTFIVE, + ZoomLevel.THREE, ZoomLevel.THREEPOINTFIVE, + ZoomLevel.FOUR, ZoomLevel.FOURPOINTFIVE, + ZoomLevel.FIVE, ZoomLevel.FIVEPOINTFIVE, + ZoomLevel.SIX, ZoomLevel.SIXPOINTFIVE, + ZoomLevel.SEVEN, ZoomLevel.SEVENPOINTFIVE, + ZoomLevel.EIGHT, ZoomLevel.EIGHTPOINTFIVE, + ZoomLevel.NINE, ZoomLevel.NINEPOINTFIVE, + ZoomLevel.TEN, ZoomLevel.TENPOINTFIVE, + ZoomLevel.ELEVEN, ZoomLevel.ELEVENTPOINTFIVE, + ZoomLevel.TWELVE, ZoomLevel.TWELVEPOINTFIVE, + ZoomLevel.THIRTEEN, ZoomLevel.THIRTEENPOINTFIVE, + ZoomLevel.FOURTEEN, ZoomLevel.FOURTEENPOINTFIVE, + ZoomLevel.FIFTEEN, ZoomLevel.FIFTEENPOINTFIVE, + ZoomLevel.SIXTEEN, ZoomLevel.SIXTEENPOINTFIVE, + ZoomLevel.SEVENTEEN, ZoomLevel.SEVENTEENPOINTFIVE, + ZoomLevel.EIGHTEEN + }; + //深蓝和高德地图下拉框层级 + public static final ZoomLevel[] BLUE_ZOOM_LEVELS = ArrayUtils.subarray(ZOOM_LEVELS, 0, 34); + public static final ZoomLevel[] GAODE_ZOOM_LEVELS = ArrayUtils.addAll(new ZoomLevel[]{ZoomLevel.AUTO}, (ZoomLevel[]) ArrayUtils.subarray(ZOOM_LEVELS, 7, 38)); + private static final String AUTO_CENTER_STRING = Toolkit.i18nText("Fine-Design_Chart_Automatic"); + private static final String CUSTOM_CENTER_STRING = Toolkit.i18nText("Fine-Design_Chart_Custom"); + + + private JPanel levelAndCenterPane; + private JPanel longAndLatPane; + + private UIComboBox zoomLevel; + private UIButtonGroup viewCenterCom; + private UISpinner longitude; + private UISpinner latitude; + + public MapStatusPane() { + initComps(); + } + + public UIComboBox getZoomLevel() { + return zoomLevel; + } + + private void initComps() { + zoomLevel = new UIComboBox(ZOOM_LEVELS); + viewCenterCom = new UIButtonGroup(new String[]{AUTO_CENTER_STRING, CUSTOM_CENTER_STRING}); + longitude = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1, 0.0); + latitude = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1, 0.0); + + double p = TableLayout.PREFERRED; + double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; + double[] rowSize = {p, p, p}; + double[] columnSize = {d, e}; + double[] column = {d, s}; + + Component[][] comps = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Layer")), zoomLevel}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_View_Center")), viewCenterCom}, + }; + levelAndCenterPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, columnSize); + + Component[][] longAndLatComps = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Longitude")), longitude}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Latitude")), latitude} + }; + longAndLatPane = TableLayout4VanChartHelper.createGapTableLayoutPane(longAndLatComps, rowSize, column); + longAndLatPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); + longAndLatPane.setVisible(false); + + this.setLayout(new BorderLayout(0, 6)); + + this.add(levelAndCenterPane, BorderLayout.NORTH); + this.add(longAndLatPane, BorderLayout.CENTER); + + viewCenterCom.addActionListener(event -> + longAndLatPane.setVisible(!isAutoViewCenter())); + } + + @Override + public Dimension getPreferredSize() { + if (longAndLatPane.isVisible()) { + return super.getPreferredSize(); + } else { + return levelAndCenterPane.getPreferredSize(); + } + } + + private boolean isAutoViewCenter() { + return viewCenterCom.getSelectedIndex() == 0; + } + + + public void resetViewCenter(VanChartMapPlot mapPlot) { + mapPlot.setViewCenter(new ViewCenter()); + viewCenterCom.setSelectedIndex(0); + longitude.setValue(0); + latitude.setValue(0); + longAndLatPane.setVisible(false); + } + + public void resetZoomLevel(VanChartMapPlot mapPlot) { + mapPlot.setZoomLevel(ZoomLevel.AUTO); + zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); + } + + public void populate(VanChartMapPlot mapPlot) { + zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); + + ViewCenter viewCenter = mapPlot.getViewCenter(); + if (viewCenter.isAuto()) { + viewCenterCom.setSelectedIndex(0); + longitude.setValue(0); + latitude.setValue(0); + } else { + viewCenterCom.setSelectedIndex(1); + longitude.setValue(viewCenter.getLongitude()); + latitude.setValue(viewCenter.getLatitude()); + } + + longAndLatPane.setVisible(!isAutoViewCenter()); + } + + public void update(VanChartMapPlot mapPlot) { + mapPlot.setZoomLevel((ZoomLevel) zoomLevel.getSelectedItem()); + + ViewCenter viewCenter = mapPlot.getViewCenter(); + if (isAutoViewCenter()) { + viewCenter.setAuto(true); + } else { + viewCenter.setAuto(false); + viewCenter.setLongitude(longitude.getValue()); + viewCenter.setLatitude(latitude.getValue()); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/TileLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/TileLayerPane.java new file mode 100644 index 000000000..4101fbd9d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/TileLayerPane.java @@ -0,0 +1,51 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextarea.UITextArea; +import com.fr.design.layout.TableLayout; +import com.fr.plugin.chart.base.GisLayer; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class TileLayerPane extends JPanel { + + private UITextArea customTileLayer; + private UITextArea attribution; + + + public TileLayerPane() { + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH - 3}; + + customTileLayer = new UITextArea(); + attribution = new UITextArea(); + Component[][] comps = new Component[][]{ + new Component[]{new UILabel("url"), customTileLayer}, + new Component[]{new UILabel("Attribution"), attribution} + }; + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); + panel.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); + + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.CENTER); + } + + public void populate(GisLayer layer) { + customTileLayer.setText(layer.getCustomTileLayer()); + attribution.setText(layer.getAttribution()); + } + + public void update(GisLayer layer) { + layer.setCustomTileLayer(customTileLayer.getText()); + layer.setAttribution(attribution.getText()); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java index a4356be87..a5e26427b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java @@ -78,7 +78,6 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { boolean enabled = !CompatibleGEOJSONHelper.isDeprecated(plot.getGeoUrl()); GUICoreUtils.setEnabled(this.getTypePane(), enabled); - GUICoreUtils.setEnabled(this.sourceChoosePane.getSourceComboBox(), enabled); checkDemosBackground(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java index bbe9d7dd4..5be437619 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java @@ -1,739 +1,113 @@ package com.fr.van.chart.map.designer.type; -import com.fr.base.Parameter; -import com.fr.base.Utils; -import com.fr.decision.webservice.v10.map.WMSFactory; -import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelper; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.icombobox.FRTreeComboBox; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextarea.UITextArea; -import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.JTemplate; -import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; -import com.fr.general.http.HttpClient; -import com.fr.plugin.chart.base.GisLayer; -import com.fr.plugin.chart.base.ViewCenter; import com.fr.plugin.chart.map.VanChartMapPlot; -import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; -import com.fr.plugin.chart.map.layer.WMSLayer; -import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; -import com.fr.plugin.chart.map.server.MapLayerConfigManager; -import com.fr.plugin.chart.type.GISLayerType; -import com.fr.plugin.chart.type.MapType; -import com.fr.plugin.chart.type.ZoomLevel; -import com.fr.stable.ArrayUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; -import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; import javax.swing.JPanel; -import javax.swing.SwingConstants; -import javax.swing.SwingWorker; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; -import java.util.ArrayList; -import java.util.List; import java.awt.BorderLayout; -import java.awt.CardLayout; import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; /** * Created by Mitisky on 16/5/11. * 地图类型选择面板,关于json资源路径/gis图层等设置面板 */ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { - private static final double[] COLUMN_SIZE = {48, TableLayout.FILL, TableLayout.PREFERRED}; - public static final ZoomLevel[] ZOOM_LEVELS = new ZoomLevel[]{ - ZoomLevel.AUTO, - ZoomLevel.ZERO, ZoomLevel.ZEROPOINTFIVE, - ZoomLevel.ONE, ZoomLevel.ONEPOINTFIVE, - ZoomLevel.TWO, ZoomLevel.TWOPOINTFIVE, - ZoomLevel.THREE, ZoomLevel.THREEPOINTFIVE, - ZoomLevel.FOUR, ZoomLevel.FOURPOINTFIVE, - ZoomLevel.FIVE, ZoomLevel.FIVEPOINTFIVE, - ZoomLevel.SIX, ZoomLevel.SIXPOINTFIVE, - ZoomLevel.SEVEN, ZoomLevel.SEVENPOINTFIVE, - ZoomLevel.EIGHT, ZoomLevel.EIGHTPOINTFIVE, - ZoomLevel.NINE, ZoomLevel.NINEPOINTFIVE, - ZoomLevel.TEN, ZoomLevel.TENPOINTFIVE, - ZoomLevel.ELEVEN, ZoomLevel.ELEVENTPOINTFIVE, - ZoomLevel.TWELVE, ZoomLevel.TWELVEPOINTFIVE, - ZoomLevel.THIRTEEN, ZoomLevel.THIRTEENPOINTFIVE, - ZoomLevel.FOURTEEN, ZoomLevel.FOURTEENPOINTFIVE, - ZoomLevel.FIFTEEN, ZoomLevel.FIFTEENPOINTFIVE, - ZoomLevel.SIXTEEN, ZoomLevel.SIXTEENPOINTFIVE, - ZoomLevel.SEVENTEEN, ZoomLevel.SEVENTEENPOINTFIVE, - ZoomLevel.EIGHTEEN - }; - //深蓝和高德地图下拉框层级 - private static final ZoomLevel[] BLUE_ZOOM_LEVELS =(ZoomLevel[]) ArrayUtils.subarray(ZOOM_LEVELS, 0, 34); - private static final ZoomLevel[] GAODE_ZOOM_LEVELS =ArrayUtils.addAll(new ZoomLevel[]{ZoomLevel.AUTO}, (ZoomLevel[])ArrayUtils.subarray(ZOOM_LEVELS, 7, 38)); - private static final String AUTO_CENTER_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"); - private static final String CUSTOM_CENTER_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom"); - private UILabel sourceTitleLabel; - private FRTreeComboBox sourceComboBox; - private MapDataTree mapDataTree; - private TreePath selectTreePath; + private GeoUrlPane geoUrlPane; - private UIComboBox gisLayer; - private JPanel layerCardPane; + private GisLayerPane gisLayerPane; - private UITextArea wmsUrl; - private UIButton connectButton; - private JPanel wmsLayerPane; - - private java.util.List wmsLayerCheckBoxs = new ArrayList(); - - private UITextArea customTileLayer; - private UITextArea attribution; - - private UIComboBox zoomLevel; - private UIButtonGroup viewCenterCom; - private JPanel longAndLatPane; - private UISpinner longitude; - private UISpinner latitude; - - private String[] oldParams; - - private UIObserverListener listener; - private String[] layers = MapLayerConfigManager.getLayerItems(); - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - @Override - public void registerChangeListener(UIObserverListener listener) { - this.listener = listener; - } - - /** - * 组件是否需要响应添加的观察者事件 - * - * @return 如果需要响应观察者事件则返回true,否则返回false - */ - @Override - public boolean shouldResponseChangeListener() { - return true; - } + private MapStatusPane mapStatusPane; public VanChartMapSourceChoosePane() { + initGeoUrlPane(); + initMapStatusPane(); + initGisLayerPane(); + this.setLayout(new BorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(10,5,0,0)); + this.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); double p = TableLayout.PREFERRED; double[] columnSize = {230}; - double[] rowSize = {p,p,p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p, p, p}; JPanel panel = new JPanel(new BorderLayout()); - panel.add(createMapSourcesPane(), BorderLayout.NORTH); - panel.add(createGISLayerPane(), BorderLayout.CENTER); - JPanel BasePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), panel); + panel.add(geoUrlPane, BorderLayout.NORTH); + panel.add(gisLayerPane, BorderLayout.CENTER); + JPanel basePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Report_Basic"), panel); + + JPanel mapStatusPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Map_Init_Status"), mapStatusPane); Component[][] comps = new Component[][]{ - new Component[]{BasePane}, - new Component[]{createMapInitStatusPane()} + new Component[]{basePane}, + new Component[]{mapStatusPaneWithTitle} }; - JPanel contentPane = TableLayoutHelper.createTableLayoutPane(comps,rowSize,columnSize); + JPanel contentPane = TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize); this.add(contentPane, BorderLayout.CENTER); } - protected boolean supportParam(){ - return true; - } - - protected TreeNode getRootNode() { - return supportParam() ? GEOJSONTreeHelper.getInstance().getRootNodeWithPara() : GEOJSONTreeHelper.getInstance().getRootNodeWithoutPara(); + public void setGeoUrlPane(GeoUrlPane geoUrlPane) { + this.geoUrlPane = geoUrlPane; } - protected UILabel createSourceTitleLabel() { - return new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area")); - } - - private JPanel createMapSourcesPane() { - mapDataTree = new MapDataTree(this.getRootNode()); - mapDataTree.setEditable(false); - mapDataTree.selectDefaultTreeNode(); - sourceComboBox = new FRTreeComboBox(mapDataTree, mapDataTree.getCellRenderer()){ - //搜索 - protected void dealSamePath(TreePath parent, TreeNode node, UITextField textField){ - String searchText = textField.getText(); - VanChartMapSourceChoosePane.this.mapDataTree.search(searchText); - } - - //选中 tree---combobox - public void setSelectedItem(Object o) { - TreePath oldPath = mapDataTree.getSelectionPath(); - Object oldText = getSelectedItem(); - if(o != null && o instanceof TreePath){ - selectTreePath =(TreePath)o; - this.tree.setSelectionPath(selectTreePath); - this.getModel().setSelectedItem(pathToString(selectTreePath)); - if(ComparatorUtils.equals(oldText, getSelectedItem()) && !ComparatorUtils.equals(oldPath, selectTreePath)) { - //point的江苏省切换到area的江苏省 - listener.doChange(); - } - } else if(o instanceof String){//list里面没有 - selectTreePath = null; - this.tree.setSelectionPath(null); - this.getModel().setSelectedItem(ChartGEOJSONHelper.getPresentNameWithPath((String) o)); - } - } - - @Override - protected String pathToString(TreePath path) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - //不显示后缀 - return ChartGEOJSONHelper.getPresentNameWithPath(node.toString()); - } - - @Override - protected boolean customSelectable(DefaultMutableTreeNode node){ - return GEOJSONTreeHelper.isSelectableTreeNode(node); - } - }; - sourceComboBox.setEditable(true); - sourceComboBox.setOnlyLeafSelectable(false); - sourceComboBox.addPopupMenuListener(popupMenuListener); - - sourceTitleLabel = createSourceTitleLabel(); - - boolean hasRefreshButton = !WorkContext.getCurrent().isLocal(); - - UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/images/control/refresh.png")); - button.setToolTipText(Toolkit.i18nText("Fine-Design_Chart_Update_Remote_Map_JSON")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - GEOJSONHelper.reset(); - GEOJSONHelper.getInstance(); - } - }); - - - double p = TableLayout.PREFERRED; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] rowSize = {p, p}; - - double[] columnSize = hasRefreshButton ? new double[]{d + 10, e - 20, 20} : new double[]{d, e}; - Component[] comps = hasRefreshButton ? new Component[]{sourceTitleLabel, sourceComboBox, button} : new Component[]{sourceTitleLabel, sourceComboBox}; - double hGap = hasRefreshButton ? 0 : TableLayout4VanChartHelper.COMPONENT_INTERVAL; - Component[][] components = new Component[][]{ - new Component[]{null,null}, - comps, - - }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, hGap, LayoutConstants.VGAP_LARGE); - } - - private JPanel createGISLayerPane() { - JPanel panel = new JPanel(new BorderLayout(0, 8)); - - gisLayer = new UIComboBox(layers); - - gisLayer.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - refreshZoomLevel(); - } - }); - - gisLayer.addPopupMenuListener(new PopupMenuListener() { - public void popupMenuCanceled(PopupMenuEvent e) { - } - - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - } - - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - - String selected = Utils.objectToString(gisLayer.getSelectedItem()); - ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem(); - - gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems())); - - gisLayer.setSelectedItem(selected); - zoomLevel.setSelectedItem(zoomSelected); - } - }); - - - gisLayer.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - checkLayerCardPane(); - } - } - }); - - final JPanel tileLyaerPane = createCustomTileLayer(); - final JPanel wmsLayerPane = createWMSPanel(); - - layerCardPane = new JPanel(new CardLayout()){ - @Override - public Dimension getPreferredSize() { - String itemName = Utils.objectToString(gisLayer.getSelectedItem()); - if (MapLayerConfigManager.isCustomLayer(itemName)) { - return tileLyaerPane.getPreferredSize(); - } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { - return wmsLayerPane.getPreferredSize(); - } - return new Dimension(0,0); - } - }; - - for(String itemName : layers){ - JPanel pane = new JPanel(); - if (MapLayerConfigManager.isCustomLayer(itemName)) { - pane = tileLyaerPane; - } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { - pane = wmsLayerPane; - } - - layerCardPane.add(pane, itemName); - } - - JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gis_Layer"), gisLayer); - - panel.add(panel1, BorderLayout.CENTER); - panel.add(layerCardPane, BorderLayout.SOUTH); - - return panel; - } - - private void refreshZoomLevel(){ - //gis图层不同,对应的缩放等级不同。 - ZoomLevel[] levels; - if (ComparatorUtils.equals(gisLayer.getSelectedItem(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { - levels = BLUE_ZOOM_LEVELS; - } else if (ComparatorUtils.equals(gisLayer.getSelectedItem(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { - levels = GAODE_ZOOM_LEVELS; - } else { - levels = ZOOM_LEVELS; - } - zoomLevel.setModel(new DefaultComboBoxModel(levels)); - } - - - private JPanel createCustomTileLayer() { - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p}; - double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH-3}; - - customTileLayer = new UITextArea(); - attribution = new UITextArea(); - Component[][] comps = new Component[][]{ - new Component[]{new UILabel("url"), customTileLayer}, - new Component[]{new UILabel("Attribution"), attribution} - }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); - panel.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); - return panel; - } - - private JPanel createWMSPanel() { - - final double p = TableLayout.PREFERRED; - double[] rowSize = {p}; - double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, 84,44}; - - - wmsUrl = new UITextArea(); - connectButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); - - Component[][] comps = new Component[][]{ - new Component[]{new UILabel("url"), wmsUrl, connectButton} - }; - JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); - northPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); - JPanel wmsPanel = new JPanel(new BorderLayout(0, 4)); - wmsLayerPane = new JPanel(new BorderLayout()); - resetWMSLayerPane(new ArrayList()); - wmsPanel.add(northPane, BorderLayout.NORTH); - wmsPanel.add(wmsLayerPane, BorderLayout.CENTER); - - connectButton.addActionListener(actionListener); - - addMouseListener(); - - return wmsPanel; - } - - ActionListener actionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - - new SwingWorker() { - private java.util.List list = new ArrayList<>(); - - @Override - protected Void doInBackground() throws Exception { - HttpClient httpClient = new HttpClient(wmsUrl.getText() + "service=WMS&request=GetCapabilities"); - httpClient.asGet(); - - if (!httpClient.isServerAlive()) { - return null; - } - - String res = httpClient.getResponseText(); - List layers = WMSFactory.readLayers(res); - list.clear(); - for (String layer : layers) { - list.add(new WMSLayer(layer, false)); - } - return null; - } - - @Override - protected void done() { - connectButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); - if(list != null && list.size() > 0) { - resetWMSLayerPane(list); - } else { - FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Invalid_WMS")); - } - } - }.execute(); - } - }; - - private void addMouseListener() { - connectButton.addMouseListener(new MouseListener() { - @Override - public void mouseClicked(MouseEvent e) { - - } - - @Override - public void mousePressed(MouseEvent e) { - connectButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Connecting_WMP")); - } - - @Override - public void mouseReleased(MouseEvent e) { - - } - - @Override - public void mouseEntered(MouseEvent e) { - - } - - @Override - public void mouseExited(MouseEvent e) { - - } - }); + @Override + public void registerChangeListener(UIObserverListener listener) { + geoUrlPane.registerChangeListener(listener); + gisLayerPane.registerChangeListener(listener); } - private void resetWMSLayerPane(java.util.List wmsLayers) { - - int size = wmsLayers.size(); - double[] rowSize = new double[size]; - Component[][] comps = new Component[size][2]; - wmsLayerCheckBoxs.clear(); - wmsLayerPane.removeAll(); - for(int i =0; i < size; i++){ - rowSize[i] = TableLayout.PREFERRED; - comps[i][0] = i == 0 ? new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_WMS_Layers"), SwingConstants.RIGHT) : null; - WMSLayer layer = wmsLayers.get(i); - UICheckBox checkBox = new UICheckBox(layer.getLayer()); - checkBox.registerChangeListener(listener); - checkBox.setToolTipText(layer.getLayer()); - checkBox.setSelected(layer.isSelected()); - comps[i][1] = checkBox; - wmsLayerCheckBoxs.add(checkBox); - } - - wmsLayerPane.add(TableLayoutHelper.createCommonTableLayoutPane(comps,rowSize, COLUMN_SIZE,0), BorderLayout.CENTER); - - VanChartMapSourceChoosePane.this.updateUI(); + @Override + public boolean shouldResponseChangeListener() { + return true; } - private JPanel createMapInitStatusPane() { - zoomLevel = new UIComboBox(ZOOM_LEVELS); - viewCenterCom = new UIButtonGroup(new String[]{AUTO_CENTER_STRING, CUSTOM_CENTER_STRING}); - longitude = new UISpinner(-Double.MAX_VALUE,Double.MAX_VALUE,1,0.0); - latitude = new UISpinner(-Double.MAX_VALUE,Double.MAX_VALUE,1,0.0); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; - double[] rowSize = {p,p,p}; - double[] columnSize = {d, e}; - double[] column = {d, s}; - - Component[][] comps = new Component[][]{ - new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Layer")), zoomLevel}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_View_Center")), viewCenterCom}, - }; - final JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps,rowSize,columnSize); - - Component[][] longAndLatComps = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Longitude")), longitude}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Latitude")), latitude} - }; - longAndLatPane =TableLayout4VanChartHelper.createGapTableLayoutPane(longAndLatComps,rowSize,column); - longAndLatPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); - longAndLatPane.setVisible(false); - - JPanel contentPane = new JPanel(new BorderLayout(0, 6)){ - - @Override - public Dimension getPreferredSize() { - if(longAndLatPane.isVisible()) { - return super.getPreferredSize(); - } else { - return northPane.getPreferredSize(); - } - } - }; - contentPane.add(northPane, BorderLayout.NORTH); - contentPane.add(longAndLatPane, BorderLayout.CENTER); - - viewCenterCom.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - longAndLatPane.setVisible(!isAutoViewCenter()); - } - }); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Init_Status"), contentPane); + protected void initGeoUrlPane() { + geoUrlPane = new GeoUrlPane(); } - private boolean isAutoViewCenter() { - return viewCenterCom.getSelectedIndex()==0; + private void initGisLayerPane() { + gisLayerPane = new GisLayerPane(); + gisLayerPane.registerZoomLevel(mapStatusPane.getZoomLevel()); } - private PopupMenuListener popupMenuListener = new PopupMenuListener() { - public void popupMenuCanceled(PopupMenuEvent e) { - } - - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - } - - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - - GEOJSONTreeHelper.reset(); - mapDataTree.changeRootNode(VanChartMapSourceChoosePane.this.getRootNode()); - GEOJSONTreeHelper.getInstance().updateParamRootNode(VanChartMapSourceChoosePane.this.getParams()); - - if(selectTreePath != null){ - mapDataTree.setSelectNodePath(CompatibleGEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString())); - selectTreePath = mapDataTree.getSelectionPath(); - } - - mapDataTree.updateUI();//因为服务器那边可能随时编辑,所以这边要重画 - mapDataTree.setSelectionPath(selectTreePath); - mapDataTree.scrollPathToVisible(selectTreePath); - } - }; - - private void checkLayerCardPane() { - CardLayout cardLayout = (CardLayout) layerCardPane.getLayout(); - cardLayout.show(layerCardPane, Utils.objectToString(gisLayer.getSelectedItem())); + private void initMapStatusPane() { + mapStatusPane = new MapStatusPane(); } public void resetComponentValue(VanChartMapPlot mapPlot) { - resetComponentValue(mapPlot, true); + geoUrlPane.resetComponentValue(mapPlot, true); //重置图层属性 - resetGisLayer(mapPlot); + gisLayerPane.resetGisLayer(mapPlot); //重置缩放等级 - resetZoomLevel(mapPlot); + mapStatusPane.resetZoomLevel(mapPlot); //重置中心点位置 - resetViewCenter(mapPlot); + mapStatusPane.resetViewCenter(mapPlot); } - protected void resetComponentValue(VanChartMapPlot mapPlot, boolean samePlotChange) { - MapType mapType = mapPlot.getMapType(); - - //获取最新的参数 - String[] params = getParams(); - - if (!ComparatorUtils.equals(oldParams, params)){ - oldParams = params; - GEOJSONTreeHelper.getInstance().updateParamRootNode(params); - } - - mapDataTree.changeRootNode(this.getRootNode()); - if(samePlotChange) { - String nodePath = ChartGEOJSONHelper.getDefaultJSONURL(); - mapPlot.setGeoUrl(nodePath); - mapDataTree.setSelectNodePath(nodePath); - selectTreePath = mapDataTree.getSelectionPath(); - sourceComboBox.setSelectedItem(selectTreePath); - } - switch (mapType){ - case CUSTOM: - sourceTitleLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area_And_Point")); - break; - case POINT: - sourceTitleLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Point")); - break; - case LINE: - sourceTitleLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Point")); - break; - default: - sourceTitleLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Area")); - } - - } - - private String[] getParams() { - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jTemplate == null){ - return new String[0]; - } - - return getParamsName((jTemplate.getJTemplateParameters())); - } - - private String[] getParamsName(Parameter[] parameters) { - String[] names = new String[parameters.length]; - for (int i = 0; i < parameters.length; i++){ - names[i] = parameters[i].getName(); - } - return names; - } - - private void resetViewCenter(VanChartMapPlot mapPlot) { - mapPlot.setViewCenter(new ViewCenter()); - viewCenterCom.setSelectedIndex(0); - longitude.setValue(0); - latitude.setValue(0); - longAndLatPane.setVisible(false); - } - - private void resetZoomLevel(VanChartMapPlot mapPlot) { - mapPlot.setZoomLevel(ZoomLevel.AUTO); - zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); - } - - private void resetGisLayer(VanChartMapPlot mapPlot) { - //TODO Bjorn 地图gis图层自动逻辑 - /* mapPlot.getGisLayer().setGisLayerType(GISLayerType.AUTO); - mapPlot.getGisLayer().setLayerName(GISLayerType.getLocString(GISLayerType.AUTO));*/ - - String layerName = mapPlot.getDefaultGisLayerName(); - - mapPlot.getGisLayer().setGisLayerType(GISLayerType.PREDEFINED_LAYER); - mapPlot.getGisLayer().setLayerName(layerName); - gisLayer.setSelectedItem(mapPlot.getGisLayer().getShowItemName()); - } public void populateBean(VanChartMapPlot mapPlot) { - resetComponentValue(mapPlot, false); - - mapDataTree.setSelectNodePath(mapPlot.getGeoUrl()); - selectTreePath = mapDataTree.getSelectionPath(); - - if(selectTreePath == null){//此url当前环境没有 - sourceComboBox.setSelectedItem(mapPlot.getGeoUrl()); - } else { - sourceComboBox.setSelectedItem(selectTreePath); - } - - GisLayer layer = mapPlot.getGisLayer(); - gisLayer.setSelectedItem(layer.getShowItemName()); - - wmsUrl.setText(layer.getWmsUrl()); - resetWMSLayerPane(layer.getWmsLayers()); - customTileLayer.setText(layer.getCustomTileLayer()); - attribution.setText(layer.getAttribution()); - - refreshZoomLevel(); - zoomLevel.setSelectedItem(mapPlot.getZoomLevel()); - - ViewCenter viewCenter = mapPlot.getViewCenter(); - if(viewCenter.isAuto()){ - viewCenterCom.setSelectedIndex(0); - longitude.setValue(0); - latitude.setValue(0); - } else { - viewCenterCom.setSelectedIndex(1); - longitude.setValue(viewCenter.getLongitude()); - latitude.setValue(viewCenter.getLatitude()); - } - - longAndLatPane.setVisible(!isAutoViewCenter()); - - checkLayerCardPane(); + geoUrlPane.populate(mapPlot); + gisLayerPane.populate(mapPlot.getGisLayer()); + mapStatusPane.populate(mapPlot); } public void updateBean(VanChartMapPlot mapPlot) { - if(!CompatibleGEOJSONHelper.isDeprecated(mapPlot.getGeoUrl())){ - mapPlot.setGeoUrl(mapDataTree.getSelectNodeJSONPath()); - } - - GisLayer layer = mapPlot.getGisLayer(); - String layerName = Utils.objectToString(gisLayer.getSelectedItem()); - - layer.setLayerName(layerName); - layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); - - switch (layer.getGisLayerType()){ - case CUSTOM_WMS_LAYER: - layer.setWmsUrl(wmsUrl.getText()); - layer.setWmsLayers(new ArrayList()); - for(UICheckBox checkBox : wmsLayerCheckBoxs){ - layer.addWmsLayer(new WMSLayer(checkBox.getText(), checkBox.isSelected())); - } - break; - case CUSTOM_TILE_LAYER: - layer.setCustomTileLayer(customTileLayer.getText()); - layer.setAttribution(attribution.getText()); - break; + if (!CompatibleGEOJSONHelper.isDeprecated(mapPlot.getGeoUrl())) { + mapPlot.setGeoUrl(geoUrlPane.update()); } - mapPlot.setZoomLevel((ZoomLevel) zoomLevel.getSelectedItem()); - - ViewCenter viewCenter = mapPlot.getViewCenter(); - if(isAutoViewCenter()){ - viewCenter.setAuto(true); - } else { - viewCenter.setAuto(false); - viewCenter.setLongitude(longitude.getValue()); - viewCenter.setLatitude(latitude.getValue()); - } - } - - public UIComboBox getSourceComboBox(){ - return this.sourceComboBox; + gisLayerPane.update(mapPlot.getGisLayer()); + mapStatusPane.update(mapPlot); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java new file mode 100644 index 000000000..19afd688f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java @@ -0,0 +1,165 @@ +package com.fr.van.chart.map.designer.type; + +import com.fr.decision.webservice.v10.map.WMSFactory; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextarea.UITextArea; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.http.HttpClient; +import com.fr.plugin.chart.base.GisLayer; +import com.fr.plugin.chart.map.layer.WMSLayer; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.SwingWorker; +import java.util.ArrayList; +import java.util.List; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-07 + */ +public class WMSLayerPane extends JPanel implements UIObserver { + private static final double[] COLUMN_SIZE = {48, TableLayout.FILL, TableLayout.PREFERRED}; + + private UITextArea wmsUrl; + private UIButton connectButton; + private JPanel wmsLayerPane; + + private List wmsLayerCheckBoxs = new ArrayList<>(); + + private UIObserverListener listener; + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + + public WMSLayerPane() { + final double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, 84, 44}; + + + wmsUrl = new UITextArea(); + connectButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); + + Component[][] comps = new Component[][]{ + new Component[]{new UILabel("url"), wmsUrl, connectButton} + }; + JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); + northPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); + + wmsLayerPane = new JPanel(new BorderLayout()); + resetWMSLayerPane(new ArrayList<>()); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(wmsLayerPane, BorderLayout.CENTER); + addListener(); + } + + private void addListener() { + connectButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + new SwingWorker() { + private java.util.List list = new ArrayList<>(); + + @Override + protected Void doInBackground() { + HttpClient httpClient = new HttpClient(wmsUrl.getText() + "service=WMS&request=GetCapabilities"); + httpClient.asGet(); + + if (!httpClient.isServerAlive()) { + return null; + } + + String res = httpClient.getResponseText(); + List layers = WMSFactory.readLayers(res); + list.clear(); + for (String layer : layers) { + list.add(new WMSLayer(layer, false)); + } + return null; + } + + @Override + protected void done() { + connectButton.setText(Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); + if (list != null && list.size() > 0) { + resetWMSLayerPane(list); + } else { + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Chart_Invalid_WMS")); + } + } + }.execute(); + } + }); + + connectButton.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + connectButton.setText(Toolkit.i18nText("Fine-Design_Chart_Connecting_WMP")); + } + }); + } + + private void resetWMSLayerPane(java.util.List wmsLayers) { + int size = wmsLayers.size(); + double[] rowSize = new double[size]; + Component[][] comps = new Component[size][2]; + wmsLayerCheckBoxs.clear(); + wmsLayerPane.removeAll(); + for (int i = 0; i < size; i++) { + rowSize[i] = TableLayout.PREFERRED; + comps[i][0] = i == 0 ? new UILabel(Toolkit.i18nText("Fine-Design_Chart_WMS_Layers"), SwingConstants.RIGHT) : null; + WMSLayer layer = wmsLayers.get(i); + UICheckBox checkBox = new UICheckBox(layer.getLayer()); + checkBox.registerChangeListener(listener); + checkBox.setToolTipText(layer.getLayer()); + checkBox.setSelected(layer.isSelected()); + comps[i][1] = checkBox; + wmsLayerCheckBoxs.add(checkBox); + } + + wmsLayerPane.add(TableLayoutHelper.createCommonTableLayoutPane(comps, rowSize, COLUMN_SIZE, 0), BorderLayout.CENTER); + + updateUI(); + } + + public void populate(GisLayer layer) { + wmsUrl.setText(layer.getWmsUrl()); + resetWMSLayerPane(layer.getWmsLayers()); + } + + public void update(GisLayer layer) { + layer.setWmsUrl(wmsUrl.getText()); + layer.setWmsLayers(new ArrayList<>()); + for (UICheckBox checkBox : wmsLayerCheckBoxs) { + layer.addWmsLayer(new WMSLayer(checkBox.getText(), checkBox.isSelected())); + } + } +} + diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java new file mode 100644 index 000000000..e5b55d749 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java @@ -0,0 +1,130 @@ +package com.fr.van.chart.pie.style; + +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +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.plugin.chart.pie.attr.PieCategoryLabelContent; +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.SummaryValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SummaryValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-10 + */ +public class VanChartPieCategoryLabelContentPane extends VanChartLabelContentPane { + + private SummaryValueFormatPaneWithCheckBox summaryValueFormatPane; + + private SummaryValueFormatPaneWithoutCheckBox richTextSummaryValueFormatPane; + + public VanChartPieCategoryLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); + } + + @Override + protected JPanel getLabelContentPane(JPanel contentPane) { + return contentPane; + } + + @Override + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setCategoryNameFormatPane(new CategoryNameFormatPaneWithCheckBox(parent, showOnPane)); + summaryValueFormatPane = new SummaryValueFormatPaneWithCheckBox(parent, showOnPane); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane)); + richTextSummaryValueFormatPane = new SummaryValueFormatPaneWithoutCheckBox(parent, showOnPane); + } + + @Override + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{getCategoryNameFormatPane(), null}, + new Component[]{summaryValueFormatPane, null}, + }; + } + + @Override + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{richTextSummaryValueFormatPane, null}, + }; + } + + @Override + protected double[] getRowSize(double p) { + return new double[]{p, p}; + } + + public JPanel createCommonStylePane() { + setTextAttrPane(new ChartTextAttrPane()); + return getTextAttrPane(); + } + + @Override + protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { + PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; + super.populateFormatPane(pieCategoryLabelContent); + summaryValueFormatPane.populate(pieCategoryLabelContent.getSummaryValueFormat()); + } + + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + getRichTextCategoryNameFormatPane(), + richTextSummaryValueFormatPane + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + pieCategoryLabelContent.getRichTextCategoryFormat(), + pieCategoryLabelContent.getRichTextSummaryValueFormat() + }; + + setRichTextAttr(new AttrTooltipRichText()); + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(pieCategoryLabelContent.getRichTextAttr()); + + checkRichEditorState(pieCategoryLabelContent); + } + + @Override + protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { + PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; + super.updateFormatPane(pieCategoryLabelContent); + summaryValueFormatPane.update(pieCategoryLabelContent.getSummaryValueFormat()); + } + + protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { + PieCategoryLabelContent pieCategoryLabelContent = (PieCategoryLabelContent) attrTooltipContent; + super.updateRichEditor(pieCategoryLabelContent); + richTextSummaryValueFormatPane.update(pieCategoryLabelContent.getRichTextSummaryValueFormat()); + } + + @Override + public void setDirty(boolean isDirty) { + getCategoryNameFormatPane().setDirty(isDirty); + summaryValueFormatPane.setDirty(isDirty); + } + + @Override + public boolean isDirty() { + return getCategoryNameFormatPane().isDirty() || summaryValueFormatPane.isDirty(); + } + + protected AttrTooltipContent createAttrTooltip() { + return new PieCategoryLabelContent(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java new file mode 100644 index 000000000..ddc6e6631 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java @@ -0,0 +1,79 @@ +package com.fr.van.chart.pie.style; + +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.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; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-12-09 + */ +public class VanChartPieValueLabelContentPane extends VanChartLabelContentPane { + + public VanChartPieValueLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); + } + + @Override + protected JPanel getLabelContentPane(JPanel contentPane) { + return contentPane; + } + + @Override + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); + } + + @Override + protected double[] getRowSize(double p) { + return new double[]{p, p, p}; + } + + @Override + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + }; + } + + @Override + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null} + }; + } + + @Override + public void setDirty(boolean isDirty) { + getSeriesNameFormatPane().setDirty(isDirty); + getValueFormatPane().setDirty(isDirty); + getPercentFormatPane().setDirty(isDirty); + } + + @Override + public boolean isDirty() { + return getSeriesNameFormatPane().isDirty() || getValueFormatPane().isDirty() || getPercentFormatPane().isDirty(); + } +} 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 a6a29339e..e316bf2b6 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 @@ -267,6 +267,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator { if (editingMouseListener.stopEditing()) { if (this != (XCreator) designer.getRootComponent()) { ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); + if (isEditing) { + EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS); + } editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter); if (isEditing) { EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS); 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 524dd8bf1..b9ce52fc5 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 @@ -194,7 +194,7 @@ public class EditingMouseListener extends MouseInputAdapter { e.translatePoint(oldX - e.getX(), oldY - e.getY()); } - private void offsetEventPoint(MouseEvent e){ + private void offsetEventPoint(MouseEvent e) { int x = designer.getRelativeX(e.getX()); int y = designer.getRelativeY(e.getY()); e.translatePoint(x - e.getX(), y - e.getY()); @@ -206,8 +206,8 @@ public class EditingMouseListener extends MouseInputAdapter { * @param e 鼠标事件 */ public void mouseReleased(MouseEvent e) { - MouseEvent transEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); - MouseEvent clickEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); + MouseEvent transEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); + MouseEvent clickEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); int oldX = e.getX(); int oldY = e.getY(); offsetEventPoint(e); @@ -240,7 +240,7 @@ public class EditingMouseListener extends MouseInputAdapter { } } - private boolean isAutoFire(MouseEvent transEvent, MouseEvent clickEvent ) { + private boolean isAutoFire(MouseEvent transEvent, MouseEvent clickEvent) { offsetEventPoint(transEvent); XCreator xCreator = designer.getComponentAt(transEvent); return (pressX != clickEvent.getX() || pressY != clickEvent.getY()) @@ -728,15 +728,15 @@ public class EditingMouseListener extends MouseInputAdapter { /** * 刷新顶层组件 - * */ - public void refreshTopXCreator(boolean isEditing){ + */ + public void refreshTopXCreator(boolean isEditing) { designer.refreshTopXCreator(isEditing); } /** * 刷新顶层组件 - * */ - public void refreshTopXCreator(){ + */ + public void refreshTopXCreator() { refreshTopXCreator(false); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormBasicWidgetPropertyPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormBasicWidgetPropertyPane.java index 138434d30..27d55ac28 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormBasicWidgetPropertyPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormBasicWidgetPropertyPane.java @@ -1,9 +1,12 @@ package com.fr.design.mainframe.widget.ui; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.form.ui.Widget; import javax.swing.BorderFactory; +import java.awt.Component; /** * Created by ibm on 2017/7/26. @@ -16,13 +19,17 @@ public class FormBasicWidgetPropertyPane extends BasicSetVisiblePropertyPane { } public UICheckBox createOtherConfig() { - enableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Enabled"), true); - enableCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic")); + enableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Enabled"), true); + enableCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_Basic")); enableCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); return enableCheckBox; } + public String obtainBasicName(){ + return Toolkit.i18nText("Fine-Design_Basic_Widget_Name"); + } + @Override public String title4PopupWindow() { return "basicProperty"; diff --git a/designer-realize/src/main/java/com/fr/design/widget/ui/BasicWidgetPropertySettingPane.java b/designer-realize/src/main/java/com/fr/design/widget/ui/BasicWidgetPropertySettingPane.java index 8b520f318..1be67275f 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/ui/BasicWidgetPropertySettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/ui/BasicWidgetPropertySettingPane.java @@ -4,6 +4,7 @@ import com.fr.design.designer.IntervalConstants; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.dialog.BasicPane; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.NoneWidget; @@ -25,16 +26,16 @@ public class BasicWidgetPropertySettingPane extends BasicPane { public BasicWidgetPropertySettingPane() { this.setLayout(new BorderLayout()); - enableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Enabled"), true); + enableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Enabled"), true); enableCheckBox.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); - visibleCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Visible"), true); + visibleCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Form_Widget_Visible"), true); visibleCheckBox.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); widgetNameComboBox = new ParameterTreeComboBox(); widgetNameComboBox.refreshTree(); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form-Widget_Name")), widgetNameComboBox}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Widget_Name")), widgetNameComboBox}, new Component[]{enableCheckBox, null}, new Component[]{visibleCheckBox, null}, }; diff --git a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java index a430faeec..d306bb179 100644 --- a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java +++ b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java @@ -456,7 +456,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { newAdd.clear(); for (int i = 0; i < cs; i++) { for (int j = 0; j < rs; j++) { - TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j ); + TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j); if (cellElement != null && ((i + c) != 0 || (r + j) != 0)) { String value = cellElement.toString(); if (!newAdd.contains(value) && !allColumnRow.contains(value)) { @@ -512,7 +512,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { private SmartJTablePaneAction a = new AbstractSmartJTablePaneAction(this, SmartInsertDBManipulationPane.this) { @Override public void doOk() { - ((KeyColumnTableModel)keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel)model); + ((KeyColumnTableModel) keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel) model); } @Override diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 3f1aa2663..495252e38 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -99,6 +99,7 @@ import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.painter.BiasTextPainter; import com.fr.report.cell.painter.CellImagePainter; import com.fr.stable.ArrayUtils; +import com.fr.stable.EssentialUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.bridge.StableFactory; import com.fr.stable.os.support.OSBasedAction; @@ -191,8 +192,8 @@ public class DesignerActivator extends Activator { justStartModules4Designer(); CalculatorProviderContext.setValueConverter(valueConverter()); - GeneralXMLTools.Object_Tokenizer = startXMLReadObjectTokenizer(); - GeneralXMLTools.Object_XML_Writer_Finder = startObjectXMLWriterFinder(); + EssentialUtils.Object_Tokenizer = startXMLReadObjectTokenizer(); + EssentialUtils.Object_XML_Writer_Finder = startObjectXMLWriterFinder(); addAdapterForPlate(); designerRegister();