|
|
|
@ -4,6 +4,7 @@ import com.fine.swing.ui.layout.Column;
|
|
|
|
|
import com.fine.swing.ui.layout.Row; |
|
|
|
|
import com.fine.swing.ui.layout.Spacer; |
|
|
|
|
import com.fine.theme.light.ui.FineRoundBorder; |
|
|
|
|
import com.fine.theme.utils.FineClientProperties; |
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
import com.fine.theme.utils.FineUIUtils; |
|
|
|
|
import com.fr.design.event.GlobalNameListener; |
|
|
|
@ -26,9 +27,9 @@ import java.util.Arrays;
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_GROUP; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.BUTTON_GROUP_POSITION; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_GROUP; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.GROUP_BUTTON_POSITION_INNER; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.GROUP_BUTTON_POSITION_LEFT; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.GROUP_BUTTON_POSITION_LEFT_BOTTOM; |
|
|
|
@ -36,6 +37,8 @@ import static com.fine.theme.utils.FineClientProperties.GROUP_BUTTON_POSITION_LE
|
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.GROUP_BUTTON_POSITION_RIGHT; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.GROUP_BUTTON_POSITION_RIGHT_BOTTOM; |
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.GROUP_BUTTON_POSITION_RIGHT_TOP; |
|
|
|
|
import static com.fine.theme.utils.FineUIStyle.IN_TOOLBAR_GROUP; |
|
|
|
|
import static com.formdev.flatlaf.FlatClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON; |
|
|
|
|
|
|
|
|
|
public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIObserver { |
|
|
|
|
private static final String UI_CLASS_ID = "ButtonGroupUI"; |
|
|
|
@ -51,6 +54,8 @@ 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); |
|
|
|
|
} |
|
|
|
@ -100,6 +105,11 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public UIButtonGroup(Icon[][] iconArray, T[] objects) { |
|
|
|
|
this(iconArray, objects, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public UIButtonGroup(Icon[][] iconArray, T[] objects, boolean inToolbar) { |
|
|
|
|
this.inToolbar = inToolbar; |
|
|
|
|
if (!ArrayUtils.isEmpty(objects) && iconArray.length == objects.length) { |
|
|
|
|
this.objectList = Arrays.asList(objects); |
|
|
|
|
} |
|
|
|
@ -192,7 +202,7 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
|
|
|
|
|
for (int j = 0; j < col; j++) { |
|
|
|
|
rowContainer.add(cell(labelButtonList.get(currentIndex)).weight(1.0)); |
|
|
|
|
currentIndex++; |
|
|
|
|
if (j != col - 1) { |
|
|
|
|
if (j != col - 1 && !inToolbar) { |
|
|
|
|
rowContainer.add(createDivider()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -219,6 +229,7 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 计算按钮位于整个按钮组件中的位置 |
|
|
|
|
* |
|
|
|
|
* @param index 按钮序号 |
|
|
|
|
* @return 按钮位置,详见 {@link com.fine.theme.utils.FineClientProperties} |
|
|
|
|
*/ |
|
|
|
@ -256,13 +267,21 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
|
|
|
|
|
|
|
|
|
|
public void setForToolBarButtonGroup(boolean isToolBarComponent) { |
|
|
|
|
if (isToolBarComponent) { |
|
|
|
|
inToolbar = true; |
|
|
|
|
for (UIToggleButton uiToggleButton : labelButtonList) { |
|
|
|
|
uiToggleButton.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON); |
|
|
|
|
FineClientProperties.setStyle(uiToggleButton, IN_TOOLBAR_GROUP); |
|
|
|
|
uiToggleButton.set4ToolbarButton(); |
|
|
|
|
uiToggleButton.setBorderPainted(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isInToolbar() { |
|
|
|
|
return inToolbar; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setEnabled(boolean enabled) { |
|
|
|
|
super.setEnabled(enabled); |
|
|
|
|