Browse Source

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

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

【改动思路】
同上
bugfix/11.0
Starryi 3 years ago
parent
commit
2d4fab1398
  1. 28
      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. 6
      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

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

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));
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
followingThemeButtonGroup.setSelectedIndex(1);
followingThemeButtonGroup.addActionListener(new ActionListener() {
@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
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();
}
}

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() {
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomStylePane();
themedCellStyleListPane = new ThemedCellStyleListPane();
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() {
@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