Browse Source

REPORT-44714 【10.0.12冒烟】设计器缓存文件记录设计器设置失效

【问题原因】实际上缓存文件的存取没有问题,但是因为此前缓存文件中记录的是上子面板的高度值,而在设计器的打开过程中,父容器的高度会变化(且有时候变为负数),导致了关闭设计器前,上子面板相对于父容器高度的比例与打开设计器之后的比例不同,视觉上就出现了面板高度的偏差
【改动思路】将之前的思路修改为,在容器高度发生变化时,根据上子面板占容器高度的比例去调整上子面板的高度,且将缓存文件中存储上子面板高度修改为存储比例
research/11.0
Yvan 4 years ago
parent
commit
0ecd214c01
  1. 27
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 38
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java
  3. 4
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  4. 16
      designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java

27
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 eastRegionToolPaneY = 300;
private int eastRegionContainerWidth = 260; private int eastRegionContainerWidth = 260;
private int westRegionToolPaneY = 300;
private int westRegionContainerWidth = 240; private int westRegionContainerWidth = 240;
private double westRegionToolPaneYRate = 0.5;
private String encryptionKey; private String encryptionKey;
private String jdkHome; private String jdkHome;
@ -440,14 +440,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.lastOpenFilePath = lastOpenFilePath; this.lastOpenFilePath = lastOpenFilePath;
} }
/** /**
* 得到西面板的上下子面板的高度区分 * 获取东面板的上子面板的高度占容器总高度的比例
*
* @return * @return
*/ */
public int getLastWestRegionToolPaneY() { public double getLastWestRegionToolPaneYRate() {
return this.westRegionToolPaneY; return westRegionToolPaneYRate;
} }
/** /**
@ -460,12 +458,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
/** /**
* 设置西面板的上下子面板的高度区分 * 设置关闭设计器前东面板的上子面板的高度占容器总高度的比例
* * @param westRegionToolPaneYRate
* @param toolPaneY
*/ */
public void setLastWestRegionToolPaneY(int toolPaneY) { public void setLastWestRegionToolPaneYRate(double westRegionToolPaneYRate) {
this.westRegionToolPaneY = toolPaneY; this.westRegionToolPaneYRate = westRegionToolPaneYRate;
} }
/** /**
@ -1610,8 +1607,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void readLastWestRegionLayout(XMLableReader reader) { private void readLastWestRegionLayout(XMLableReader reader) {
String tmpVal; String tmpVal;
if ((tmpVal = reader.getAttrAsString("toolPaneY", null)) != null) { if ((tmpVal = reader.getAttrAsString("toolPaneYRate", null)) != null) {
this.setLastWestRegionToolPaneY(Integer.parseInt(tmpVal)); this.setLastWestRegionToolPaneYRate(Double.parseDouble(tmpVal));
} }
if ((tmpVal = reader.getAttrAsString("containerWidth", null)) != null) { if ((tmpVal = reader.getAttrAsString("containerWidth", null)) != null) {
this.setLastWestRegionContainerWidth(Integer.parseInt(tmpVal)); this.setLastWestRegionContainerWidth(Integer.parseInt(tmpVal));
@ -1934,8 +1931,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void writeLastWestRegionLayout(XMLPrintWriter writer) { private void writeLastWestRegionLayout(XMLPrintWriter writer) {
writer.startTAG("LastWestRegionLayout"); writer.startTAG("LastWestRegionLayout");
if (this.getLastWestRegionToolPaneY() >= 0) { if (this.getLastWestRegionToolPaneYRate() >= 0) {
writer.attr("toolPaneY ", this.getLastWestRegionToolPaneY()); writer.attr("toolPaneYRate", this.getLastWestRegionToolPaneYRate());
} }
if (this.getLastWestRegionContainerWidth() >= 0) { if (this.getLastWestRegionContainerWidth() >= 0) {
writer.attr("containerWidth", this.getLastWestRegionContainerWidth()); writer.attr("containerWidth", this.getLastWestRegionContainerWidth());

38
designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java

@ -1,12 +1,10 @@
package com.fr.design.gui.icontainer; package com.fr.design.gui.icontainer;
import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.collections.utils.MathUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -46,6 +44,7 @@ public class UIResizableContainer extends JPanel {
private boolean isDownPaneVisible = true ; private boolean isDownPaneVisible = true ;
private int paraHeight; private int paraHeight;
private int parentHeight = -1; private int parentHeight = -1;
private double toolPaneYRate;
public UIResizableContainer(int direction) { public UIResizableContainer(int direction) {
this(new JPanel(), new JPanel(), direction); this(new JPanel(), new JPanel(), direction);
@ -159,12 +158,19 @@ public class UIResizableContainer extends JPanel {
} }
/** /**
* 设置关闭设计器前最后一次上下子面板的高度 * 获取上子面板高度占容器总高度的比例
* * @return
* @param toolPaneY */
public double getToolPaneYRate() {
return toolPaneYRate;
}
/**
* 设置关闭设计器前最新的上子面板的高度比例
* @param toolPaneYRate
*/ */
public void setLastToolPaneY(int toolPaneY) { public void setLastToolPaneYRate(double toolPaneYRate) {
this.toolPaneY = toolPaneY; this.toolPaneYRate = toolPaneYRate;
} }
/** /**
@ -242,12 +248,12 @@ public class UIResizableContainer extends JPanel {
if (parentHeight == -1) { if (parentHeight == -1) {
// 初始化下parentheight,存一下当前的父容器height // 初始化下parentheight,存一下当前的父容器height
parentHeight = parent.getHeight(); parentHeight = parent.getHeight();
} else if (parentHeight != parent.getHeight()) { } else if (parentHeight != parent.getHeight() && parent.getHeight() > 0) {
// parentHeight与父容器height不等时,代表用户调整分辨率或者dpi了,此时调整toolPaneY // parentHeight与父容器height不等时,代表用户调整分辨率或者dpi或者容器高度发生变化了,此时调整toolPaneY
toolPaneY = toolPaneY * parent.getHeight() / parentHeight; toolPaneY = Math.min((int) (parent.getHeight() * toolPaneYRate), (parent.getHeight() - toolPaneHeight));
toolPaneY = Math.min(toolPaneY, (parent.getHeight() - toolPaneHeight));
parentHeight = parent.getHeight(); parentHeight = parent.getHeight();
} }
System.out.println("toolPaneY:" + toolPaneY + ", rate:" + toolPaneYRate);
} }
@Override @Override
@ -371,6 +377,7 @@ public class UIResizableContainer extends JPanel {
toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y;
toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; toolPaneY = toolPaneY < 0 ? 0 : toolPaneY;
toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight();
adjustToolPaneYRate();
refreshContainer(); refreshContainer();
} }
}); });
@ -392,8 +399,10 @@ public class UIResizableContainer extends JPanel {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (e.getX() <= ARROW_RANGE) { if (e.getX() <= ARROW_RANGE) {
toolPaneY = 0; toolPaneY = 0;
UIResizableContainer.this.adjustToolPaneYRate();
} else if (e.getX() >= getWidth() - ARROW_RANGE) { } else if (e.getX() >= getWidth() - ARROW_RANGE) {
toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight(); toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight();
UIResizableContainer.this.adjustToolPaneYRate();
} else { } else {
return; return;
} }
@ -554,4 +563,11 @@ public class UIResizableContainer extends JPanel {
jf.setSize(500, 500); jf.setSize(500, 500);
jf.setVisible(true); jf.setVisible(true);
} }
/**
* 当toolPaneY发生变化时也需要调整toolPaneYRate
*/
private void adjustToolPaneYRate() {
this.toolPaneYRate = ((double) toolPaneY) / this.getHeight();
}
} }

4
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().setLastOpenFile(jt.getEditingFILE().getPath());
} }
DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneYRate(
WestRegionContainerPane.getInstance().getToolPaneY()); WestRegionContainerPane.getInstance().getToolPaneYRate());
DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth(
WestRegionContainerPane.getInstance().getContainerWidth()); WestRegionContainerPane.getInstance().getContainerWidth());
DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY(

16
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() { public static final WestRegionContainerPane getInstance() {
if (THIS == null) { if (THIS == null) {
THIS = new WestRegionContainerPane(); THIS = new WestRegionContainerPane();
THIS.setLastToolPaneY(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneY()); THIS.setLastToolPaneYRate(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneYRate());
THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth()); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth());
} }
return THIS; return THIS;
@ -32,11 +32,11 @@ public class WestRegionContainerPane extends UIResizableContainer {
public WestRegionContainerPane() { public WestRegionContainerPane() {
super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT); super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT);
setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
GeneralContext.listenPluginRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) { GeneralContext.listenPluginRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) {
@Override @Override
public void on(PluginEvent event) { public void on(PluginEvent event) {
@ -47,15 +47,15 @@ public class WestRegionContainerPane extends UIResizableContainer {
} }
} }
}, new PluginFilter() { }, new PluginFilter() {
@Override @Override
public boolean accept(PluginContext context) { public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign); return context.contain(PluginModule.ExtraDesign);
} }
}); });
setContainerWidth(165); setContainerWidth(165);
setBackground(UIConstants.TREE_BACKGROUND); setBackground(UIConstants.TREE_BACKGROUND);
} }
} }

Loading…
Cancel
Save