Browse Source

Pull request #13539: REPORT-99485 修复UIButtonGroup样式导致无限绘制的问题

Merge in DESIGN/design from ~VITO/c-design:newui to newui

* commit '220952a02fbcbee6c9d5992e5ff3e88452371091':
  无jira任务 遗漏
  REPORT-99485 修复UIButtonGroup样式导致无限绘制的问题
newui
vito-刘恒霖 11 months ago
parent
commit
30e5ebe140
  1. 12
      designer-base/src/main/java/com/fine/theme/light/ui/FineButtonGroupUI.java
  2. 32
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java
  3. 11
      designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonGroupStoryBoard.java
  4. 2
      designer-realize/src/main/java/com/fr/design/actions/ButtonGroupAction.java
  5. 8
      designer-realize/src/main/java/com/fr/design/actions/cell/style/AlignmentAction.java

12
designer-base/src/main/java/com/fine/theme/light/ui/FineButtonGroupUI.java

@ -1,11 +1,8 @@
package com.fine.theme.light.ui;
import com.fr.design.gui.ibutton.UIButtonGroup;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.PanelUI;
import java.awt.Graphics;
/**
* 按钮组UI应用于 {@link com.fr.design.gui.ibutton.UIButtonGroup}
@ -26,15 +23,6 @@ public class FineButtonGroupUI extends PanelUI {
return new FineButtonGroupUI();
}
@Override
public void update(Graphics g, JComponent c) {
UIButtonGroup group = (UIButtonGroup) c;
if (!group.isInToolbar()) {
c.setBorder(new FineRoundBorder());
}
super.update(g, c);
}
@Override
public void uninstallUI(JComponent c) {
super.uninstallUI(c);

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

@ -54,8 +54,6 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
private UIObserverListener uiObserverListener;
private boolean autoFireStateChanged = true;
private boolean inToolbar = false;
public UIButtonGroup(String[] textArray) {
this(textArray, null);
}
@ -101,6 +99,7 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
};
initButton(labelButton, index);
}
setBorder(new FineRoundBorder());
initLayout(getCols());
}
@ -109,7 +108,6 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
}
public UIButtonGroup(Icon[][] iconArray, T[] objects, boolean inToolbar) {
this.inToolbar = inToolbar;
if (!ArrayUtils.isEmpty(objects) && iconArray.length == objects.length) {
this.objectList = Arrays.asList(objects);
}
@ -142,7 +140,8 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
};
initButton(labelButton, index);
}
initLayout(getCols());
setForToolBarButtonGroup(inToolbar);
initLayout(getCols(), inToolbar);
}
public UIButtonGroup(String[] textArray, T[] objects) {
@ -177,6 +176,7 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
};
initButton(labelButton, index);
}
setBorder(new FineRoundBorder());
initLayout(getCols());
}
@ -194,13 +194,17 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
return new int[]{totalButtonSize};
}
protected void initLayout(int[] cols) {
private void initLayout(int[] cols) {
initLayout(cols, false);
}
protected void initLayout(int[] cols, boolean inToolbar) {
int currentIndex = 0;
for (int row = 0; row < cols.length; row++) {
int col = cols[row];
Row rowContainer = new Row();
for (int j = 0; j < col; j++) {
rowContainer.add(cell(labelButtonList.get(currentIndex)).weight(1.0));
rowContainer.add(cell(getLabelButtonList().get(currentIndex)).weight(1.0));
currentIndex++;
if (j != col - 1 && !inToolbar) {
rowContainer.add(createDivider());
@ -213,6 +217,10 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
}
}
private List<UIToggleButton> getLabelButtonList() {
return labelButtonList;
}
private Spacer createDivider() {
Spacer spacer = new Spacer(FineUIScale.scale(1));
spacer.setBorder(new LineBorder(FineUIUtils.getUIColor("defaultBorderColor", "Component.borderColor")));
@ -265,20 +273,16 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
isClick = changeFlag;
}
public void setForToolBarButtonGroup(boolean isToolBarComponent) {
if (isToolBarComponent) {
inToolbar = true;
private void setForToolBarButtonGroup(boolean inToolbar) {
if (inToolbar) {
for (UIToggleButton button : labelButtonList) {
button.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON);
FineUIStyle.setStyle(button, IN_TOOLBAR_GROUP);
button.setBorderPainted(false);
}
} else {
setBorder(new FineRoundBorder());
}
repaint();
}
public boolean isInToolbar() {
return inToolbar;
}
@Override

11
designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonGroupStoryBoard.java

@ -61,10 +61,9 @@ public class ButtonGroupStoryBoard extends StoryBoard {
ArrayUtils.toArray(new LazyIcon("preview"), new LazyIcon("save"))
));
private static Component getToolbar(){
private static Component getToolbar() {
UIToolbar toolbar = new UIToolbar();
UIButtonGroup<Object> objectUIButtonGroup = new UIButtonGroup<>(iconArrayWithWhite(),null,true);
objectUIButtonGroup.setForToolBarButtonGroup(true);
UIButtonGroup<Object> objectUIButtonGroup = new UIButtonGroup<>(iconArrayWithWhite(), null, true);
toolbar.add(objectUIButtonGroup);
return toolbar;
}
@ -77,15 +76,15 @@ public class ButtonGroupStoryBoard extends StoryBoard {
return iconArrayWithWhite.getValue();
}
private String[] fiveTextArray() {
private String[] fiveTextArray() {
return ArrayUtils.toArray("按钮1", "按钮2", "按钮3", "按钮4", "按钮5");
}
private String[] sevenTextArray() {
private String[] sevenTextArray() {
return ArrayUtils.toArray("按钮1", "按钮2", "按钮3", "按钮4", "按钮5", "按钮6", "按钮7");
}
private String[] sixTextArray() {
private String[] sixTextArray() {
return ArrayUtils.toArray("按钮1", "按钮2", "按钮3", "按钮4", "按钮5", "按钮6");
}

2
designer-realize/src/main/java/com/fr/design/actions/ButtonGroupAction.java

@ -48,7 +48,7 @@ public abstract class ButtonGroupAction extends ElementCaseAction{
@Override
public UIButtonGroup<Integer> createToolBarComponent() {
if(group == null) {
group = new UIButtonGroup<Integer>(iconArray, valueArray, true);
group = new UIButtonGroup<>(iconArray, valueArray, true);
group.addActionListener(this);
}
return group;

8
designer-realize/src/main/java/com/fr/design/actions/cell/style/AlignmentAction.java

@ -16,6 +16,8 @@ import com.fr.stable.Constants;
import javax.swing.Icon;
import static com.fr.design.i18n.Toolkit.i18nText;
public class AlignmentAction extends ButtonGroupAction implements StyleActionInterface {
@ -105,8 +107,10 @@ public class AlignmentAction extends ButtonGroupAction implements StyleActionInt
public UIButtonGroup<Integer> createToolBarComponent() {
UIButtonGroup<Integer> group = super.createToolBarComponent();
if (group != null) {
group.setForToolBarButtonGroup(true);
group.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Right")});
group.setAllToolTips(new String[]{
i18nText("Fine-Design_Basic_StyleAlignment_Left"),
i18nText("Fine-Design_Form_Center"),
i18nText("Fine-Design_Basic_StyleAlignment_Right")});
}
return group;
}

Loading…
Cancel
Save