Browse Source

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

【问题原因】
1. 修改UIButtonGroup及UIToggleButton的setSelected方法
接口
2. JList仅在选中项改变时触犯stateChanged

【改动思路】
同上
bugfix/11.0
Starryi 3 years ago
parent
commit
2d4fab1398
  1. 32
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java
  2. 9
      designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java
  3. 8
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java
  4. 1
      designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java
  5. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  6. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java
  7. 1
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java
  8. 2
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java
  9. 1
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

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

8
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) { if (this.isSelected != isSelected) {
this.isSelected = isSelected; this.isSelected = isSelected;
fireSelectedChanged(); if (fireChanged) {
fireSelectedChanged();
}
refresh(isSelected); refresh(isSelected);
} }
} }
@ -175,7 +177,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (isEnabled() && !isEventBannded) { if (isEnabled() && !isEventBannded) {
setSelectedWithFireListener(!isSelected()); setSelected(!isSelected(), true);
} }
} }
}; };

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

@ -47,6 +47,7 @@ public class FollowingThemePane extends BasicPane implements UIObserver {
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
followingThemeButtonGroup.setSelectedIndex(1); followingThemeButtonGroup.setSelectedIndex(1);
followingThemeButtonGroup.addActionListener(new ActionListener() { followingThemeButtonGroup.addActionListener(new ActionListener() {
@Override @Override

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 //记录改变前的plotID
String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider(ChartProvider.class).getID(); String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider(ChartProvider.class).getID();
changeCollectionSelected(getButtonName()); changeCollectionSelected(getButtonName());
setSelectedWithFireListener(true); setSelected(true, true);
fireSelectedChanged(); 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()) { if (isEnabled()) {
noSelected(); noSelected();
changeAxisSelected(getButtonName()); changeAxisSelected(getButtonName());
setSelectedWithFireListener(true); setSelected(true, true);
fireSelectedChanged(); fireSelectedChanged();
} }
} }

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

@ -50,6 +50,7 @@ public class StylePane extends BasicPane implements UIObserver {
public StylePane() { public StylePane() {
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomStylePane(); customStylePane = new CustomStylePane();
themedCellStyleListPane = new ThemedCellStyleListPane(); themedCellStyleListPane = new ThemedCellStyleListPane();
panes[0] = createThemedStylePane(); panes[0] = createThemedStylePane();

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() { styleList.addListSelectionListener(new ListSelectionListener() {
@Override @Override
public void valueChanged(ListSelectionEvent e) { public void valueChanged(ListSelectionEvent e) {
if (changeListener != null) { if (e.getValueIsAdjusting() && changeListener != null) {
changeListener.stateChanged(new ChangeEvent(styleList)); 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(); previewArea = new CellStylePreviewPane();
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomFloatStyleSettingPane(); customStylePane = new CustomFloatStyleSettingPane();
themedFloatStyleSettingPane = new ThemedFloatStyleSettingPane(); themedFloatStyleSettingPane = new ThemedFloatStyleSettingPane();
panes[0] = createThemedStylePane(); panes[0] = createThemedStylePane();

Loading…
Cancel
Save