Browse Source

Pull request #6248: REPORT-58744 【主题切换】撤销操作后,样式设置不符合预期

Merge in DESIGN/design from ~STARRYI/design:REPORT-58744/release/11.0 to release/11.0

* commit 'fcaf293f105fdf6efcf3686549fd33ec0a311c34':
  REPORT-58744 【主题切换】撤销操作后,样式设置不符合预期
  REPORT-58744 【主题切换】撤销操作后,样式设置不符合预期
bugfix/11.0
starryi 3 years ago
parent
commit
af075c7426
  1. 12
      designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java
  2. 47
      designer-base/src/main/java/com/fr/design/gui/frpane/AttributeChangeUtils.java
  3. 28
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java
  4. 9
      designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java
  5. 6
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java
  6. 9
      designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java
  7. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  8. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java
  9. 40
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java
  10. 2
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java
  11. 1
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

12
designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java

@ -24,6 +24,16 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
private AttributeChangeListener listener;
private String globalName = "";
private boolean autoFireAttributesChanged = true;
public boolean isAutoFireAttributesChanged() {
return this.autoFireAttributesChanged;
}
public void setAutoFireAttributesChanged(boolean autoFireAttributesChanged) {
this.autoFireAttributesChanged = autoFireAttributesChanged;
}
protected AbstractAttrNoScrollPane() {
initAll();
}
@ -127,10 +137,12 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
public void attributeChanged() {
synchronized (this) {
if (listener != null) {
if (autoFireAttributesChanged) {
listener.attributeChange();
}
}
}
}
/**
* 返回图标的路径

47
designer-base/src/main/java/com/fr/design/gui/frpane/AttributeChangeUtils.java

@ -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();
}
}

28
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java

@ -37,6 +37,8 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
private boolean isToolBarComponent = false;
private boolean isClick;
private boolean autoFireStateChanged = true;
public UIButtonGroup(String[] textArray) {
this(textArray, null);
}
@ -72,7 +74,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
if (globalNameListener != null) {
globalNameListener.setGlobalName(buttonGroupName);
}
setSelectedWithFireChanged(index);
setSelectedIndex(index, autoFireStateChanged);
}
};
}
@ -108,7 +110,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
if (globalNameListener != null) {
globalNameListener.setGlobalName(buttonGroupName);
}
setSelectedWithFireChanged(index);
setSelectedIndex(index, autoFireStateChanged);
}
};
}
@ -175,7 +177,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
if (globalNameListener != null) {
globalNameListener.setGlobalName(buttonGroupName);
}
setSelectedWithFireChanged(index);
setSelectedIndex(index, autoFireStateChanged);
}
};
}
@ -253,6 +255,10 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
g2d.setClip(oldClip);
}
public void setAutoFireStateChanged(boolean autoFireStateChanged) {
this.autoFireStateChanged = autoFireStateChanged;
}
/**
* setSelectedItem
*
@ -287,13 +293,14 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
return selectedIndex;
}
protected void setSelectedWithFireChanged(int newSelectedIndex) {
protected void setSelectedIndex(int newSelectedIndex, boolean fireChanged) {
if (selectedIndex != newSelectedIndex) {
selectedIndex = newSelectedIndex;
for (int i = 0; i < labelButtonList.size(); i++) {
if (i == selectedIndex) {
labelButtonList.get(i).setSelectedWithFireListener(true);
} else {
labelButtonList.get(i).setSelected(false);
labelButtonList.get(i).setSelected(i == selectedIndex, false);
}
if (fireChanged) {
fireStateChanged();
}
}
}
@ -304,10 +311,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
* @param newSelectedIndex
*/
public void setSelectedIndex(int newSelectedIndex) {
selectedIndex = newSelectedIndex;
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).setSelected(i == selectedIndex);
}
setSelectedIndex(newSelectedIndex, true);
}
private void fireStateChanged() {

9
designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java

@ -63,13 +63,8 @@ public class UITabGroup extends UIButtonGroup<Integer> {
}
@Override
protected void setSelectedWithFireChanged(int newSelectedIndex) {
if (selectedIndex != newSelectedIndex) {
selectedIndex = newSelectedIndex;
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).setSelected(i == selectedIndex);
}
}
protected void setSelectedIndex(int newSelectedIndex, boolean fireChanged) {
super.setSelectedIndex(newSelectedIndex, fireChanged);
tabChanged(newSelectedIndex);
}
}

6
designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java

@ -142,10 +142,12 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
}
}
public void setSelectedWithFireListener(boolean isSelected) {
public void setSelected(boolean isSelected, boolean fireChanged) {
if (this.isSelected != isSelected) {
this.isSelected = isSelected;
if (fireChanged) {
fireSelectedChanged();
}
refresh(isSelected);
}
}
@ -175,7 +177,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
@Override
public void mouseClicked(MouseEvent e) {
if (isEnabled() && !isEventBannded) {
setSelectedWithFireListener(!isSelected());
setSelected(!isSelected(), true);
}
}
};

9
designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java

@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicPane;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.frpane.AttributeChangeUtils;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
@ -47,16 +48,20 @@ public class FollowingThemePane extends BasicPane implements UIObserver {
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
followingThemeButtonGroup.setSelectedIndex(1);
followingThemeButtonGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AttributeChangeUtils.changeComposedUI(FollowingThemePane.this, false, new AttributeChangeUtils.UIChangeAction() {
@Override
public void changeComposedUI() {
for (FollowingThemeActionChangeListener changeListener : changeListeners) {
changeListener.onFollowingTheme(isFollowingTheme());
}
invalidate();
// 与主题相关的属性面板更新完毕后,再通知外层更新数据
}
});
if (uiObserverListener != null) {
uiObserverListener.doChange();
}

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -660,7 +660,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
//记录改变前的plotID
String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider(ChartProvider.class).getID();
changeCollectionSelected(getButtonName());
setSelectedWithFireListener(true);
setSelected(true, true);
fireSelectedChanged();
//需要先更新,最后重构面板

2
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java

@ -356,7 +356,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> {
if (isEnabled()) {
noSelected();
changeAxisSelected(getButtonName());
setSelectedWithFireListener(true);
setSelected(true, true);
fireSelectedChanged();
}
}

40
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java

@ -6,6 +6,7 @@ import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.AttributeChangeUtils;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
@ -50,6 +51,7 @@ public class StylePane extends BasicPane implements UIObserver {
public StylePane() {
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomStylePane();
themedCellStyleListPane = new ThemedCellStyleListPane();
panes[0] = createThemedStylePane();
@ -72,9 +74,31 @@ public class StylePane extends BasicPane implements UIObserver {
followingThemeButtonGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() {
@Override
public void changeComposedUI() {
int selectedIndex = followingThemeButtonGroup.getSelectedIndex();
onFollowingThemeSettingChanged(selectedIndex, selectedIndex == 0);
}
});
fireStateChanged();
}
});
UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Setting"));
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
return TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{ new Component[] { uiLabel, followingThemeButtonGroup} },
new double[] { p }, new double[] { p, f},
IntervalConstants.INTERVAL_L1, 0);
}
private void onFollowingThemeSettingChanged(int selectedIndex, boolean isFollowingTheme) {
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]);
if (selectedIndex == 1) {
if (!isFollowingTheme) {
// 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致
NameStyle lastSelectedNameStyle = themedCellStyleListPane.updateBean();
if (lastSelectedNameStyle != null) {
@ -92,20 +116,6 @@ public class StylePane extends BasicPane implements UIObserver {
// 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格
themedCellStyleListPane.reset();
}
fireStateChanged();
}
});
UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Setting"));
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
return TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{ new Component[] { uiLabel, followingThemeButtonGroup} },
new double[] { p }, new double[] { p, f},
IntervalConstants.INTERVAL_L1, 0);
}
protected JPanel createTabbedContentPane() {

2
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java

@ -47,7 +47,7 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
styleList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (changeListener != null) {
if (e.getValueIsAdjusting() && changeListener != null) {
changeListener.stateChanged(new ChangeEvent(styleList));
}
}

1
designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

@ -78,6 +78,7 @@ public class ReportStylePane extends BasicPane {
previewArea = new CellStylePreviewPane();
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomFloatStyleSettingPane();
themedFloatStyleSettingPane = new ThemedFloatStyleSettingPane();
panes[0] = createThemedStylePane();

Loading…
Cancel
Save