Browse Source
【问题原因】 目前的撤销回退机制是基于AbstractNoScrollPane的自动注册 回调来完成的,灵活性较低,且存在重复注册监听器的问题, 导致一个交互操作会产生多个撤销回退,不适用于日趋复杂的 交互逻辑,后面需要想办法重新设计下。 针对主题的撤销回退,主要原因是跟随主题切换到自定义时,需要将 自定义样式面板设置为跟随主题时一样的配置,但因为上述自动发送 属性更新的逻辑,导致中间产生了大量无效的撤销回退状态。因此 需要临时禁止AbstractAttrNoScrollPane的自动发送属性变化 事件的行为,待面板内容更新完毕后,再恢复自动发送. 【改动思路】 同上bugfix/11.0
Starryi
3 years ago
4 changed files with 99 additions and 27 deletions
@ -0,0 +1,47 @@
|
||||
package com.fr.design.gui.frpane; |
||||
|
||||
import java.awt.Component; |
||||
import java.awt.Container; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2021/9/17 |
||||
*/ |
||||
public class AttributeChangeUtils { |
||||
private static AbstractAttrNoScrollPane findNearestAttrNoScrollPaneAncestor(Component c) { |
||||
for(Container p = c.getParent(); p != null; p = p.getParent()) { |
||||
if (p instanceof AbstractAttrNoScrollPane) { |
||||
return (AbstractAttrNoScrollPane) p; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static void changeComposedUI(Component composedComponent, boolean fireMiddleStateChanged, UIChangeAction action) { |
||||
AbstractAttrNoScrollPane attrPane = findNearestAttrNoScrollPaneAncestor(composedComponent); |
||||
boolean oldAutoFire = true; |
||||
|
||||
if (!fireMiddleStateChanged) { |
||||
// 禁止属性面板自动处理属性更新
|
||||
if (attrPane != null) { |
||||
oldAutoFire = attrPane.isAutoFireAttributesChanged(); |
||||
attrPane.setAutoFireAttributesChanged(false); |
||||
} |
||||
} |
||||
|
||||
// 更新UI
|
||||
action.changeComposedUI(); |
||||
|
||||
if (!fireMiddleStateChanged) { |
||||
// 恢复属性面板自动处理属性更新
|
||||
if (attrPane != null) { |
||||
attrPane.setAutoFireAttributesChanged(oldAutoFire); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public interface UIChangeAction { |
||||
void changeComposedUI(); |
||||
} |
||||
} |
Loading…
Reference in new issue