@ -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