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 c6488d3300..8d7c536455 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; @@ -440,14 +440,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.lastOpenFilePath = lastOpenFilePath; } - /** - * 得到西面板的上下子面板的高度区分 - * + * 获取东面板的上子面板的高度占容器总高度的比例 * @return */ - public int getLastWestRegionToolPaneY() { - return this.westRegionToolPaneY; + public double getLastWestRegionToolPaneYRate() { + return westRegionToolPaneYRate; } /** @@ -460,12 +458,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } /** - * 设置西面板的上下子面板的高度区分 - * - * @param toolPaneY + * 设置关闭设计器前,东面板的上子面板的高度占容器总高度的比例 + * @param westRegionToolPaneYRate */ - public void setLastWestRegionToolPaneY(int toolPaneY) { - this.westRegionToolPaneY = toolPaneY; + public void setLastWestRegionToolPaneYRate(double westRegionToolPaneYRate) { + this.westRegionToolPaneYRate = westRegionToolPaneYRate; } /** @@ -1610,8 +1607,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void readLastWestRegionLayout(XMLableReader reader) { String tmpVal; - if ((tmpVal = reader.getAttrAsString("toolPaneY", null)) != null) { - this.setLastWestRegionToolPaneY(Integer.parseInt(tmpVal)); + if ((tmpVal = reader.getAttrAsString("toolPaneYRate", null)) != null) { + this.setLastWestRegionToolPaneYRate(Double.parseDouble(tmpVal)); } if ((tmpVal = reader.getAttrAsString("containerWidth", null)) != null) { this.setLastWestRegionContainerWidth(Integer.parseInt(tmpVal)); @@ -1934,8 +1931,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void writeLastWestRegionLayout(XMLPrintWriter writer) { writer.startTAG("LastWestRegionLayout"); - if (this.getLastWestRegionToolPaneY() >= 0) { - writer.attr("toolPaneY ", this.getLastWestRegionToolPaneY()); + if (this.getLastWestRegionToolPaneYRate() >= 0) { + writer.attr("toolPaneYRate", this.getLastWestRegionToolPaneYRate()); } if (this.getLastWestRegionContainerWidth() >= 0) { writer.attr("containerWidth", this.getLastWestRegionContainerWidth()); 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 4f4ac9e3b5..cc1067eb7a 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 @@ -1,12 +1,10 @@ package com.fr.design.gui.icontainer; -import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.DesignerContext; import com.fr.stable.Constants; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.stable.collections.utils.MathUtils; import javax.swing.*; import java.awt.*; @@ -46,6 +44,7 @@ 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); @@ -159,12 +158,19 @@ public class UIResizableContainer extends JPanel { } /** - * 设置关闭设计器前最后一次上下子面板的高度 - * - * @param toolPaneY + * 获取上子面板高度占容器总高度的比例 + * @return + */ + public double getToolPaneYRate() { + return toolPaneYRate; + } + + /** + * 设置关闭设计器前最新的上子面板的高度比例 + * @param toolPaneYRate */ - public void setLastToolPaneY(int toolPaneY) { - this.toolPaneY = toolPaneY; + public void setLastToolPaneYRate(double toolPaneYRate) { + this.toolPaneYRate = toolPaneYRate; } /** @@ -242,12 +248,12 @@ public class UIResizableContainer extends JPanel { if (parentHeight == -1) { // 初始化下parentheight,存一下当前的父容器height parentHeight = parent.getHeight(); - } else if (parentHeight != parent.getHeight()) { - // parentHeight与父容器height不等时,代表用户调整分辨率或者dpi了,此时调整toolPaneY - toolPaneY = toolPaneY * parent.getHeight() / parentHeight; - toolPaneY = Math.min(toolPaneY, (parent.getHeight() - toolPaneHeight)); + } else if (parentHeight != parent.getHeight() && parent.getHeight() > 0) { + // parentHeight与父容器height不等时,代表用户调整分辨率或者dpi或者容器高度发生变化了,此时调整toolPaneY + toolPaneY = Math.min((int) (parent.getHeight() * toolPaneYRate), (parent.getHeight() - toolPaneHeight)); parentHeight = parent.getHeight(); } + System.out.println("toolPaneY:" + toolPaneY + ", rate:" + toolPaneYRate); } @Override @@ -371,6 +377,7 @@ 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(); } }); @@ -392,8 +399,10 @@ 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; } @@ -554,4 +563,11 @@ 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 490b4e7e99..a5eafa0c07 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().setLastWestRegionToolPaneY( - WestRegionContainerPane.getInstance().getToolPaneY()); + DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneYRate( + WestRegionContainerPane.getInstance().getToolPaneYRate()); DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( WestRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( 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 23c642dbd4..358fba411e 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.setLastToolPaneY(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneY()); + THIS.setLastToolPaneYRate(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneYRate()); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth()); } return THIS; @@ -32,11 +32,11 @@ public class WestRegionContainerPane extends UIResizableContainer { public WestRegionContainerPane() { super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT); - + setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); - + GeneralContext.listenPluginRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) { - + @Override public void on(PluginEvent event) { @@ -47,15 +47,15 @@ public class WestRegionContainerPane extends UIResizableContainer { } } }, new PluginFilter() { - + @Override public boolean accept(PluginContext context) { - + return context.contain(PluginModule.ExtraDesign); } }); - + setContainerWidth(165); setBackground(UIConstants.TREE_BACKGROUND); } -} \ No newline at end of file +}