@ -51,6 +51,7 @@ public class StylePane extends BasicPane implements UIObserver {
private final List < UIObserverListener > observerListeners = new ArrayList < > ( ) ;
private Style backupStyleFromPopulating = Style . DEFAULT_STYLE ;
private boolean isFollowingThemeSettingChanged = false ;
public StylePane ( ) {
followingThemeButtonGroup = new UIButtonGroup < > ( FOLLOWING_THEME_STRING_ARRAYS ) ;
@ -77,6 +78,7 @@ public class StylePane extends BasicPane implements UIObserver {
followingThemeButtonGroup . addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
isFollowingThemeSettingChanged = true ;
AttributeChangeUtils . changeComposedUI ( StylePane . this , false , new AttributeChangeUtils . UIChangeAction ( ) {
@Override
public void changeComposedUI ( ) {
@ -85,6 +87,7 @@ public class StylePane extends BasicPane implements UIObserver {
}
} ) ;
fireStateChanged ( ) ;
isFollowingThemeSettingChanged = false ;
}
} ) ;
@ -103,25 +106,33 @@ public class StylePane extends BasicPane implements UIObserver {
cardLayout . show ( contentPane , FOLLOWING_THEME_STRING_ARRAYS [ selectedIndex ] ) ;
if ( ! isFollowingTheme ) {
// 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致
NameStyle lastSelectedNameStyle = nameStyleListPane . updateNameStyle ( ) ;
if ( lastSelectedNameStyle ! = null ) {
Style lastSelectedRealStyle = lastSelectedNameStyle . getRealStyle ( ) ;
try {
lastSelectedRealStyle = ( Style ) lastSelectedRealStyle . clone ( ) ;
if ( lastSelectedRealStyle ! = null ) {
customStylePane . populateBean ( lastSelectedRealStyle ) ;
customStylePane . dealWithBorder ( ) ;
}
} catch ( CloneNotSupportedException ex ) {
FineLoggerFactory . getLogger ( ) . error ( ex . getMessage ( ) , ex ) ;
}
}
syncCustomStylePaneBySelectedNameStyle ( ) ;
} else {
// 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格
nameStyleListPane . reset ( ) ;
}
}
private void syncCustomStylePaneBySelectedNameStyle ( ) {
NameStyle lastSelectedNameStyle = nameStyleListPane . updateNameStyle ( ) ;
if ( lastSelectedNameStyle ! = null ) {
Style lastSelectedRealStyle = lastSelectedNameStyle . getRealStyle ( ) ;
try {
lastSelectedRealStyle = ( Style ) lastSelectedRealStyle . clone ( ) ;
if ( lastSelectedRealStyle ! = null ) {
customStylePane . populateBean ( lastSelectedRealStyle ) ;
customStylePane . dealWithBorder ( ) ;
}
} catch ( CloneNotSupportedException ex ) {
FineLoggerFactory . getLogger ( ) . error ( ex . getMessage ( ) , ex ) ;
}
}
}
public boolean isFollowingThemeSettingChanged ( ) {
return isFollowingThemeSettingChanged ;
}
protected JPanel createTabbedContentPane ( ) {
JPanel contentPane = new JPanel ( cardLayout ) {
@Override
@ -161,14 +172,22 @@ public class StylePane extends BasicPane implements UIObserver {
return com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Style" ) ;
}
public void setSelectedIndex ( int index ) {
public boolean isFollowingTheme ( ) {
return getSelectedIndex ( ) = = 0 ;
}
public void setFollowingTheme ( boolean followingTheme ) {
setSelectedIndex ( followingTheme ? 0 : 1 ) ;
}
private void setSelectedIndex ( int index ) {
if ( 0 < = index & & index < FOLLOWING_THEME_STRING_ARRAYS . length ) {
followingThemeButtonGroup . setSelectedIndex ( index ) ;
cardLayout . show ( contentPane , FOLLOWING_THEME_STRING_ARRAYS [ index ] ) ;
}
}
public int getSelectedIndex ( ) {
private int getSelectedIndex ( ) {
return followingThemeButtonGroup . getSelectedIndex ( ) ;
}
@ -185,11 +204,11 @@ public class StylePane extends BasicPane implements UIObserver {
}
public void setSelctedByName ( String id ) {
setSelectedIndex ( ComparatorUtils . equals ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Custom" ) , id ) ? 1 : 0 ) ;
setFollowingTheme ( ! ComparatorUtils . equals ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Custom" ) , id ) ) ;
}
public CellBorderStyle updateBorderStyle ( ) {
if ( getSelectedIndex ( ) = = 0 ) {
if ( isFollowingTheme ( ) ) {
return nameStyleListPane . updateBorderStyle ( ) ;
} else if ( customStylePane . isBorderPaneSelected ( ) ) {
return customStylePane . updateBorderStyle ( ) ;
@ -199,7 +218,7 @@ public class StylePane extends BasicPane implements UIObserver {
public Style updateBean ( ) {
Style finalStyle = null ;
if ( getSelectedIndex ( ) = = 0 ) {
if ( isFollowingTheme ( ) ) {
finalStyle = nameStyleListPane . updateNameStyle ( ) ;
}
if ( finalStyle = = null ) {
@ -215,7 +234,7 @@ public class StylePane extends BasicPane implements UIObserver {
if ( style instanceof NameStyle ) {
NameStyle nameStyle = ( NameStyle ) style ;
setSelectedIndex ( 0 ) ;
setFollowingTheme ( true ) ;
nameStyleListPane . populateNameStyle ( nameStyle ) ;
Style realStyle = nameStyle . getRealStyle ( ) ;
try {
@ -225,7 +244,7 @@ public class StylePane extends BasicPane implements UIObserver {
e . printStackTrace ( ) ;
}
} else {
setSelectedIndex ( 1 ) ;
setFollowingTheme ( false ) ;
customStylePane . populateBean ( style ) ;
}
//单元格配置界面是单例 所以直接在populate的时候把跟随主题的按钮组设置不可见