@ -4,19 +4,28 @@ import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig ;
import com.fr.base.Utils ;
import com.fr.design.beans.BasicBeanPane ;
import com.fr.design.dialog.FineJOptionPane ;
import com.fr.design.gui.controlpane.JListControlPane ;
import com.fr.design.gui.controlpane.NameObjectCreator ;
import com.fr.design.gui.controlpane.NameableCreator ;
import com.fr.design.gui.controlpane.ShortCut4JControlPane ;
import com.fr.design.gui.ilist.JNameEdList ;
import com.fr.design.gui.ilist.ModNameActionListener ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.menu.ShortCut ;
import com.fr.general.ComparatorUtils ;
import com.fr.general.NameObject ;
import com.fr.stable.Nameable ;
import com.fr.stable.StringUtils ;
import javax.swing.JOptionPane ;
import javax.swing.SwingUtilities ;
import javax.swing.event.ListSelectionEvent ;
import javax.swing.event.ListSelectionListener ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Iterator ;
import java.util.List ;
/ * *
* @author Bjorn
@ -31,6 +40,38 @@ public class ChartPreStyleListPane extends JListControlPane {
super ( ) ;
this . chartPreStyleManagerPane = chartPreStyleManagerPane ;
initListener ( ) ;
addModNameActionListener ( ( int index , String oldName , String newName ) - > {
if ( ComparatorUtils . equals ( oldName , newName ) ) {
return ;
}
String [ ] allNames = nameableList . getAllNames ( ) ;
allNames [ index ] = StringUtils . EMPTY ;
if ( StringUtils . isEmpty ( newName ) ) {
showTipDialog ( Toolkit . i18nText ( "Fine-Design_Chart_Fill_Style_Empty_Name_Tip" ) ) ;
nameableList . setNameAt ( oldName , index ) ;
return ;
}
if ( isNameRepeated ( new List [ ] { Arrays . asList ( allNames ) } , newName ) ) {
showTipDialog ( Toolkit . i18nText ( "Fine-Design_Chart_Fill_Style_Exist_Name_Tip" , newName ) ) ;
nameableList . setNameAt ( oldName , index ) ;
return ;
}
populateSelectedValue ( ) ;
} ) ;
}
private void showTipDialog ( String content ) {
FineJOptionPane . showMessageDialog ( SwingUtilities . getWindowAncestor ( ChartPreStyleListPane . this ) ,
content ,
Toolkit . i18nText ( "Fine-Design_Basic_Alert" ) ,
JOptionPane . WARNING_MESSAGE ) ;
}
@Override
protected JNameEdList createJNameList ( ) {
JNameEdList jNameList = super . createJNameList ( ) ;
jNameList . setReplaceEmptyName ( false ) ;
return jNameList ;
}
/ * *