@ -41,400 +41,414 @@ import com.jme3.export.binary.BinaryImporter;
* @author Marcin Roguski ( Kaelthas )
* @author Marcin Roguski ( Kaelthas )
* /
* /
public class ConfigDialog extends AbstractConfigDialog {
public class ConfigDialog extends AbstractConfigDialog {
private static final long serialVersionUID = 2863364888664674247L ;
private static final Logger LOGGER = Logger . getLogger ( ConfigDialog . class . getName ( ) ) ;
private static final long serialVersionUID = 2863364888664674247L ;
private static final Logger LOGGER = Logger . getLogger ( ConfigDialog . class . getName ( ) ) ;
private String baseFolderName ;
private String baseFolderName ;
private File configFile ; //the config file
private File configFile ; //the config file
private Map < String , BlenderKeyConfiguration > configMap ; //the blender key configuration map
private Map < String , BlenderKeyConfiguration > configMap ; //the blender key configuration map
private BlenderKeyConfiguration blenderKeyConfiguration ; //the configuration for the files
private BlenderKeyConfiguration blenderKeyConfiguration ; //the configuration for the files
private IConfigExecutable configExecutable ; //this is called after clicking the 'OK' button
private ConfigExecutable configExecutable ; //this is called after clicking the 'OK' button
/ * *
/ * *
* Constructor . Builds the whole window and stores its data .
* Constructor . Builds the whole window and stores its data .
* @param testAssetsFolderName the path to test files folder
* @param testAssetsFolderName the path to test files folder
* /
* /
public ConfigDialog ( String baseFolderName , IConfigExecutable configExecutable ) {
public ConfigDialog ( String baseFolderName , ConfigExecutable configExecutable ) {
if ( baseFolderName = = null ) {
if ( baseFolderName = = null ) {
throw new IllegalArgumentException ( "No test asset folder given!" ) ;
throw new IllegalArgumentException ( "No test asset folder given!" ) ;
}
}
if ( configExecutable = = null ) {
if ( configExecutable = = null ) {
throw new IllegalArgumentException ( "No config executable given!" ) ;
throw new IllegalArgumentException ( "No config executable given!" ) ;
}
}
this . baseFolderName = baseFolderName ;
this . baseFolderName = baseFolderName ;
this . configExecutable = configExecutable ;
this . configExecutable = configExecutable ;
this . configMap = new HashMap < String , ConfigDialog . BlenderKeyConfiguration > ( ) ;
this . configMap = new HashMap < String , ConfigDialog . BlenderKeyConfiguration > ( ) ;
//setting up version selection (as a folder list in a compo box)
//setting up version selection (as a folder list in a compo box)
File baseFolder = new File ( baseFolderName ) ;
File baseFolder = new File ( baseFolderName ) ;
if ( ! baseFolder . exists ( ) | | ! baseFolder . isDirectory ( ) ) {
if ( ! baseFolder . exists ( ) | | ! baseFolder . isDirectory ( ) ) {
throw new IllegalArgumentException ( "The given base folder path either does not exists or does not point to a directory!" ) ;
throw new IllegalArgumentException ( "The given base folder path either does not exists or does not point to a directory!" ) ;
}
}
File [ ] folders = baseFolder . listFiles ( new FileFilter ( ) {
File [ ] folders = baseFolder . listFiles ( new FileFilter ( ) {
@Override
public boolean accept ( File file ) {
@Override
return file . isDirectory ( ) & & file . getName ( ) . charAt ( 0 ) ! = '.' ;
public boolean accept ( File file ) {
}
return file . isDirectory ( ) & & file . getName ( ) . charAt ( 0 ) ! = '.' ;
} ) ;
}
for ( File folder : folders ) {
} ) ;
( ( DefaultComboBoxModel ) jComboBoxVersionSelection . getModel ( ) ) . addElement ( folder . getName ( ) ) ;
for ( File folder : folders ) {
configMap . put ( folder . getName ( ) , null ) ;
( ( DefaultComboBoxModel ) jComboBoxVersionSelection . getModel ( ) ) . addElement ( folder . getName ( ) ) ;
}
configMap . put ( folder . getName ( ) , null ) ;
this . initListeners ( ) ;
}
this . initListeners ( ) ;
jComboBoxVersionSelection . setSelectedIndex ( 0 ) ;
}
jComboBoxVersionSelection . setSelectedIndex ( 0 ) ;
}
/ * *
* This method returns the selected blender key .
/ * *
* @return the selected blender key
* This method returns the selected blender key .
* /
* @return the selected blender key
public BlenderKey getSelectedBlenderKey ( ) {
* /
return blenderKeyConfiguration . lastUsedKey ;
public BlenderKey getSelectedBlenderKey ( ) {
}
return blenderKeyConfiguration . lastUsedKey ;
}
/ * *
* This method prepares the blender files ' list .
/ * *
* @param testAssetsFolderName the path to test files folder
* This method prepares the blender files ' list .
* @return array of blender files
* @param testAssetsFolderName the path to test files folder
* /
* @return array of blender files
private File [ ] prepareFilesList ( String testAssetsFolderName ) {
* /
File testAssetsFolder = new File ( testAssetsFolderName ) ;
private File [ ] prepareFilesList ( String testAssetsFolderName ) {
File testAssetsFolder = new File ( testAssetsFolderName ) ;
//loading blender files
File [ ] blenderFiles = testAssetsFolder . listFiles ( new FileFilter ( ) {
//loading blender files
@Override
File [ ] blenderFiles = testAssetsFolder . listFiles ( new FileFilter ( ) {
public boolean accept ( File file ) {
return file . isFile ( ) & & file . canRead ( ) & & file . getName ( ) . endsWith ( ".blend" ) ;
@Override
}
public boolean accept ( File file ) {
} ) ;
return file . isFile ( ) & & file . canRead ( ) & & file . getName ( ) . endsWith ( ".blend" ) ;
}
//loading the blender files configuration
} ) ;
File [ ] files = testAssetsFolder . listFiles ( new FileFilter ( ) {
@Override
//loading the blender files configuration
public boolean accept ( File file ) {
File [ ] files = testAssetsFolder . listFiles ( new FileFilter ( ) {
return file . isFile ( ) & & file . canRead ( ) & & file . getName ( ) . endsWith ( ".conf" ) ;
}
@Override
} ) ;
public boolean accept ( File file ) {
if ( files = = null | | files . length = = 0 ) {
return file . isFile ( ) & & file . canRead ( ) & & file . getName ( ) . endsWith ( ".conf" ) ;
blenderKeyConfiguration = new BlenderKeyConfiguration ( blenderFiles . length ) ;
}
} ) ;
} else {
if ( files = = null | | files . length = = 0 ) {
BinaryImporter jmeImporter = new BinaryImporter ( ) ;
blenderKeyConfiguration = new BlenderKeyConfiguration ( blenderFiles . length ) ;
String instructionToUser = files . length = = 1 ?
"No other config file to load! No configuration set!" :
} else {
"Please choose different config file!" ;
BinaryImporter jmeImporter = new BinaryImporter ( ) ;
do {
String instructionToUser = files . length = = 1
if ( files . length > 1 ) {
? "No other config file to load! No configuration set!"
configFile = ( File ) JOptionPane . showInputDialog ( null , "Choose the config file!" , "Config file selection" ,
: "Please choose different config file!" ;
JOptionPane . INFORMATION_MESSAGE , null , files , files [ 0 ] ) ;
do {
} else {
if ( files . length > 1 ) {
configFile = files [ 0 ] ;
configFile = ( File ) JOptionPane . showInputDialog ( null , "Choose the config file!" , "Config file selection" ,
}
JOptionPane . INFORMATION_MESSAGE , null , files , files [ 0 ] ) ;
if ( configFile = = null ) {
} else {
JOptionPane . showMessageDialog ( this , "No config file selected!\nEmpty configuration will be created!" ,
configFile = files [ 0 ] ;
"No configuration selected" , JOptionPane . INFORMATION_MESSAGE ) ;
}
blenderKeyConfiguration = new BlenderKeyConfiguration ( blenderFiles . length ) ;
if ( configFile = = null ) {
} else {
JOptionPane . showMessageDialog ( this , "No config file selected!\nEmpty configuration will be created!" ,
try {
"No configuration selected" , JOptionPane . INFORMATION_MESSAGE ) ;
Savable loadedData = jmeImporter . load ( configFile ) ;
blenderKeyConfiguration = new BlenderKeyConfiguration ( blenderFiles . length ) ;
if ( loadedData instanceof BlenderKeyConfiguration ) {
} else {
blenderKeyConfiguration = ( BlenderKeyConfiguration ) loadedData ;
try {
} else {
Savable loadedData = jmeImporter . load ( configFile ) ;
LOGGER . warning ( "Cannot load data drom the given file!" ) ;
if ( loadedData instanceof BlenderKeyConfiguration ) {
JOptionPane . showMessageDialog ( this , "The data stored in the config file is of invalid type!\n"
blenderKeyConfiguration = ( BlenderKeyConfiguration ) loadedData ;
+ instructionToUser , "Config data error" , JOptionPane . ERROR_MESSAGE ) ;
} else {
}
LOGGER . warning ( "Cannot load data drom the given file!" ) ;
} catch ( IOException e ) {
JOptionPane . showMessageDialog ( this , "The data stored in the config file is of invalid type!\n"
JOptionPane . showMessageDialog ( this , "Unable to load configuration! Reason: " + e . getLocalizedMessage ( ) ,
+ instructionToUser , "Config data error" , JOptionPane . ERROR_MESSAGE ) ;
"Loading data error" , JOptionPane . ERROR_MESSAGE ) ;
}
LOGGER . severe ( "Unable to load configuration" ) ;
} catch ( IOException e ) {
} catch ( Exception e ) {
JOptionPane . showMessageDialog ( this , "Unable to load configuration! Reason: " + e . getLocalizedMessage ( ) ,
JOptionPane . showMessageDialog ( this , "Unable to load configuration!" ,
"Loading data error" , JOptionPane . ERROR_MESSAGE ) ;
"Loading data error" , JOptionPane . ERROR_MESSAGE ) ;
LOGGER . severe ( "Unable to load configuration" ) ;
LOGGER . log ( Level . SEVERE , "Unable to load configuration due to unpredicted error!" , e ) ;
} catch ( Exception e ) {
}
JOptionPane . showMessageDialog ( this , "Unable to load configuration!" ,
}
"Loading data error" , JOptionPane . ERROR_MESSAGE ) ;
} while ( blenderKeyConfiguration = = null & & files . length > 1 ) ;
LOGGER . log ( Level . SEVERE , "Unable to load configuration due to unpredicted error!" , e ) ;
}
}
configFile = new File ( testAssetsFolder , "test.conf" ) ;
}
} while ( blenderKeyConfiguration = = null & & files . length > 1 ) ;
jCheckBoxUseModelKey . setSelected ( blenderKeyConfiguration . useModelKey ) ;
}
configFile = new File ( testAssetsFolder , "test.conf" ) ;
//enlisting the files in the list
DefaultListModel defaultListModel = ( DefaultListModel ) jListBlenderFiles . getModel ( ) ;
jCheckBoxUseModelKey . setSelected ( blenderKeyConfiguration . useModelKey ) ;
defaultListModel . removeAllElements ( ) ;
for ( int i = 0 ; i < blenderFiles . length ; + + i ) {
//enlisting the files in the list
defaultListModel . addElement ( new FileListItem ( blenderFiles [ i ] ) ) ;
DefaultListModel defaultListModel = ( DefaultListModel ) jListBlenderFiles . getModel ( ) ;
}
defaultListModel . removeAllElements ( ) ;
return blenderFiles ;
for ( int i = 0 ; i < blenderFiles . length ; + + i ) {
}
defaultListModel . addElement ( new FileListItem ( blenderFiles [ i ] ) ) ;
}
/ * *
return blenderFiles ;
* This method fills the properties panel with blender key data .
}
* @param blenderKey the belnder key data
* /
/ * *
private void setBlenderKey ( BlenderKey blenderKey ) {
* This method fills the properties panel with blender key data .
//setting properties
* @param blenderKey the belnder key data
BlenderTableModel propertiesModel = ( BlenderTableModel ) jTableProperties . getModel ( ) ;
* /
int rowCount = propertiesModel . getRowCount ( ) ;
private void setBlenderKey ( BlenderKey blenderKey ) {
for ( int i = 0 ; i < rowCount ; + + i ) {
//setting properties
propertiesModel . removeRow ( 0 ) ;
BlenderTableModel propertiesModel = ( BlenderTableModel ) jTableProperties . getModel ( ) ;
}
int rowCount = propertiesModel . getRowCount ( ) ;
Field [ ] fields = blenderKey . getClass ( ) . getDeclaredFields ( ) ;
for ( int i = 0 ; i < rowCount ; + + i ) {
for ( Field field : fields ) {
propertiesModel . removeRow ( 0 ) ;
}
field . setAccessible ( true ) ;
Field [ ] fields = blenderKey . getClass ( ) . getDeclaredFields ( ) ;
if ( ! "animations" . equalsIgnoreCase ( field . getName ( ) ) & &
for ( Field field : fields ) {
( field . getModifiers ( ) & Modifier . STATIC ) = = 0 ) {
try {
field . setAccessible ( true ) ;
propertiesModel . addRow ( new Object [ ] { field . getName ( ) , field . get ( blenderKey ) } ) ;
if ( ! "animations" . equalsIgnoreCase ( field . getName ( ) )
} catch ( IllegalArgumentException e ) {
& & ( field . getModifiers ( ) & Modifier . STATIC ) = = 0 ) {
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
try {
} catch ( IllegalAccessException e ) {
propertiesModel . addRow ( new Object [ ] { field . getName ( ) , field . get ( blenderKey ) } ) ;
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
} catch ( IllegalArgumentException e ) {
}
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
}
} catch ( IllegalAccessException e ) {
}
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
}
//setting animations
}
DefaultTableModel animationsModel = ( DefaultTableModel ) jTableAnimations . getModel ( ) ;
}
rowCount = animationsModel . getRowCount ( ) ;
for ( int i = 0 ; i < rowCount ; + + i ) {
//setting animations
animationsModel . removeRow ( 0 ) ;
DefaultTableModel animationsModel = ( DefaultTableModel ) jTableAnimations . getModel ( ) ;
}
rowCount = animationsModel . getRowCount ( ) ;
Map < String , Map < String , int [ ] > > animations = blenderKey . getAnimations ( ) ;
for ( int i = 0 ; i < rowCount ; + + i ) {
if ( animations ! = null ) {
animationsModel . removeRow ( 0 ) ;
for ( Entry < String , Map < String , int [ ] > > animationEntry : animations . entrySet ( ) ) {
}
for ( Entry < String , int [ ] > animDataEntry : animationEntry . getValue ( ) . entrySet ( ) ) {
Map < String , Map < String , int [ ] > > animations = blenderKey . getAnimations ( ) ;
int [ ] frames = animDataEntry . getValue ( ) ;
if ( animations ! = null ) {
animationsModel . addRow ( new Object [ ] { animationEntry . getKey ( ) , animDataEntry . getKey ( ) ,
for ( Entry < String , Map < String , int [ ] > > animationEntry : animations . entrySet ( ) ) {
Integer . valueOf ( frames [ 0 ] ) , Integer . valueOf ( frames [ 1 ] ) } ) ;
for ( Entry < String , int [ ] > animDataEntry : animationEntry . getValue ( ) . entrySet ( ) ) {
}
int [ ] frames = animDataEntry . getValue ( ) ;
}
animationsModel . addRow ( new Object [ ] { animationEntry . getKey ( ) , animDataEntry . getKey ( ) ,
}
Integer . valueOf ( frames [ 0 ] ) , Integer . valueOf ( frames [ 1 ] ) } ) ;
}
this . jButtonOK . setEnabled ( true ) ;
}
this . jButtonOK . requestFocusInWindow ( ) ;
}
this . jButtonAddAnimation . setEnabled ( true ) ;
}
this . jButtonOK . setEnabled ( true ) ;
this . jButtonOK . requestFocusInWindow ( ) ;
/ * *
this . jButtonAddAnimation . setEnabled ( true ) ;
* This method stores the current blender config .
}
* @param configuration the blender config to store
* /
/ * *
private void storeConfig ( BlenderKeyConfiguration configuration ) {
* This method stores the current blender config .
if ( configuration . lastUsedKey ! = null ) { //reading animations
* @param configuration the blender config to store
DefaultTableModel animationsTableModel = ( DefaultTableModel ) jTableAnimations . getModel ( ) ;
* /
if ( configuration . lastUsedKey . getAnimations ( ) ! = null ) {
private void storeConfig ( BlenderKeyConfiguration configuration ) {
configuration . lastUsedKey . getAnimations ( ) . clear ( ) ;
if ( configuration . lastUsedKey ! = null ) { //reading animations
}
DefaultTableModel animationsTableModel = ( DefaultTableModel ) jTableAnimations . getModel ( ) ;
int animCounter = 0 ;
if ( configuration . lastUsedKey . getAnimations ( ) ! = null ) {
for ( int i = 0 ; i < animationsTableModel . getRowCount ( ) ; + + i ) {
configuration . lastUsedKey . getAnimations ( ) . clear ( ) ;
String objectName = ( String ) animationsTableModel . getValueAt ( i , 0 ) ;
}
String animName = ( String ) animationsTableModel . getValueAt ( i , 1 ) ;
int animCounter = 0 ;
Number startFrame = ( Number ) animationsTableModel . getValueAt ( i , 2 ) ;
for ( int i = 0 ; i < animationsTableModel . getRowCount ( ) ; + + i ) {
Number stopFrame = ( Number ) animationsTableModel . getValueAt ( i , 3 ) ;
String objectName = ( String ) animationsTableModel . getValueAt ( i , 0 ) ;
if ( objectName ! = null & & animName ! = null & & startFrame . intValue ( ) < = stopFrame . intValue ( ) ) {
String animName = ( String ) animationsTableModel . getValueAt ( i , 1 ) ;
configuration . lastUsedKey . addAnimation ( objectName , animName , startFrame . intValue ( ) , stopFrame . intValue ( ) ) ;
Number startFrame = ( Number ) animationsTableModel . getValueAt ( i , 2 ) ;
+ + animCounter ;
Number stopFrame = ( Number ) animationsTableModel . getValueAt ( i , 3 ) ;
}
if ( objectName ! = null & & animName ! = null & & startFrame . intValue ( ) < = stopFrame . intValue ( ) ) {
}
configuration . lastUsedKey . addAnimation ( objectName , animName , startFrame . intValue ( ) , stopFrame . intValue ( ) ) ;
if ( animCounter < animationsTableModel . getRowCount ( ) ) {
+ + animCounter ;
JOptionPane . showMessageDialog ( ConfigDialog . this , "Some animations had errors!\nThey had not been added!" ,
}
"Invalid animations definitions" , JOptionPane . WARNING_MESSAGE ) ;
}
}
if ( animCounter < animationsTableModel . getRowCount ( ) ) {
}
JOptionPane . showMessageDialog ( ConfigDialog . this , "Some animations had errors!\nThey had not been added!" ,
//getting the key type
"Invalid animations definitions" , JOptionPane . WARNING_MESSAGE ) ;
configuration . useModelKey = jCheckBoxUseModelKey . isSelected ( ) ;
}
configuration . logLevel = JRadioButtonLevel . getSelectedLevel ( ) ;
}
//getting the key type
//storing the config
configuration . useModelKey = jCheckBoxUseModelKey . isSelected ( ) ;
JmeExporter jmeExporter = new BinaryExporter ( ) ;
configuration . logLevel = JRadioButtonLevel . getSelectedLevel ( ) ;
try {
if ( ! jmeExporter . save ( configuration , configFile ) ) {
//storing the config
JOptionPane . showMessageDialog ( ConfigDialog . this , "Unable to save the config data!" , "Config save problem" , JOptionPane . ERROR_MESSAGE ) ;
JmeExporter jmeExporter = new BinaryExporter ( ) ;
}
try {
} catch ( IOException e ) {
if ( ! jmeExporter . save ( configuration , configFile ) ) {
JOptionPane . showMessageDialog ( ConfigDialog . this , "Error occured during config saving!\nReason: " + e . getLocalizedMessage ( ) ,
JOptionPane . showMessageDialog ( ConfigDialog . this , "Unable to save the config data!" , "Config save problem" , JOptionPane . ERROR_MESSAGE ) ;
"Config save problem" , JOptionPane . ERROR_MESSAGE ) ;
}
}
} catch ( IOException e ) {
}
JOptionPane . showMessageDialog ( ConfigDialog . this , "Error occured during config saving!\nReason: " + e . getLocalizedMessage ( ) ,
"Config save problem" , JOptionPane . ERROR_MESSAGE ) ;
/ * *
}
* This method initiates components listeners .
}
* /
private void initListeners ( ) {
/ * *
//selection of blender version
* This method initiates components listeners .
jComboBoxVersionSelection . addActionListener ( new ActionListener ( ) {
* /
@Override
private void initListeners ( ) {
public void actionPerformed ( ActionEvent evt ) {
//selection of blender version
//save the previous congifuration
jComboBoxVersionSelection . addActionListener ( new ActionListener ( ) {
if ( blenderKeyConfiguration ! = null ) {
ConfigDialog . this . storeConfig ( blenderKeyConfiguration ) ;
@Override
blenderKeyConfiguration = null ;
public void actionPerformed ( ActionEvent evt ) {
}
//save the previous congifuration
if ( blenderKeyConfiguration ! = null ) {
//load new configuration
ConfigDialog . this . storeConfig ( blenderKeyConfiguration ) ;
File [ ] blenderFiles = ConfigDialog . this . prepareFilesList ( baseFolderName + '/' + jComboBoxVersionSelection . getSelectedItem ( ) . toString ( ) ) ;
blenderKeyConfiguration = null ;
if ( blenderKeyConfiguration . lastUsedKey ! = null ) {
}
for ( int i = 0 ; i < blenderFiles . length ; + + i ) {
if ( blenderFiles [ i ] . getPath ( ) . equalsIgnoreCase ( blenderKeyConfiguration . lastUsedKey . getName ( ) ) ) {
//load new configuration
jListBlenderFiles . setSelectedIndex ( i ) ;
File [ ] blenderFiles = ConfigDialog . this . prepareFilesList ( baseFolderName + '/' + jComboBoxVersionSelection . getSelectedItem ( ) . toString ( ) ) ;
break ;
if ( blenderKeyConfiguration . lastUsedKey ! = null ) {
}
for ( int i = 0 ; i < blenderFiles . length ; + + i ) {
}
if ( blenderFiles [ i ] . getPath ( ) . equalsIgnoreCase ( blenderKeyConfiguration . lastUsedKey . getName ( ) ) ) {
}
jListBlenderFiles . setSelectedIndex ( i ) ;
if ( blenderKeyConfiguration . logLevel = = null ) {
break ;
blenderKeyConfiguration . logLevel = Level . INFO ;
}
}
}
JRadioButtonLevel . setSelectedLevel ( blenderKeyConfiguration . logLevel ) ;
}
}
if ( blenderKeyConfiguration . logLevel = = null ) {
} ) ;
blenderKeyConfiguration . logLevel = Level . INFO ;
//selection of the file changes the config on the right
}
jListBlenderFiles . addListSelectionListener ( new ListSelectionListener ( ) {
JRadioButtonLevel . setSelectedLevel ( blenderKeyConfiguration . logLevel ) ;
@Override
}
public void valueChanged ( ListSelectionEvent evt ) {
} ) ;
BlenderKeyConfiguration config = ConfigDialog . this . blenderKeyConfiguration ;
//selection of the file changes the config on the right
FileListItem selectedItem = ( FileListItem ) ConfigDialog . this . jListBlenderFiles . getSelectedValue ( ) ;
jListBlenderFiles . addListSelectionListener ( new ListSelectionListener ( ) {
if ( selectedItem ! = null ) {
String fileName = selectedItem . getFile ( ) . getName ( ) ;
@Override
config . lastUsedKey = config . blenderKeys . get ( fileName ) ;
public void valueChanged ( ListSelectionEvent evt ) {
if ( config . lastUsedKey = = null ) {
BlenderKeyConfiguration config = ConfigDialog . this . blenderKeyConfiguration ;
config . lastUsedKey = new BlenderKey ( selectedItem . getFile ( ) . getPath ( ) ) ;
FileListItem selectedItem = ( FileListItem ) ConfigDialog . this . jListBlenderFiles . getSelectedValue ( ) ;
config . blenderKeys . put ( fileName , config . lastUsedKey ) ;
if ( selectedItem ! = null ) {
}
String fileName = selectedItem . getFile ( ) . getName ( ) ;
ConfigDialog . this . setBlenderKey ( config . lastUsedKey ) ;
config . lastUsedKey = config . blenderKeys . get ( fileName ) ;
} else {
if ( config . lastUsedKey = = null ) {
config . lastUsedKey = null ;
config . lastUsedKey = new BlenderKey ( selectedItem . getFile ( ) . getPath ( ) ) ;
}
config . blenderKeys . put ( fileName , config . lastUsedKey ) ;
}
}
} ) ;
ConfigDialog . this . setBlenderKey ( config . lastUsedKey ) ;
jTableProperties . getModel ( ) . addTableModelListener ( new TableModelListener ( ) {
} else {
@Override
config . lastUsedKey = null ;
public void tableChanged ( TableModelEvent evt ) {
}
if ( evt . getType ( ) = = TableModelEvent . UPDATE ) {
}
BlenderKeyConfiguration config = ConfigDialog . this . blenderKeyConfiguration ;
} ) ;
int row = evt . getFirstRow ( ) ;
jTableProperties . getModel ( ) . addTableModelListener ( new TableModelListener ( ) {
String name = ( String ) jTableProperties . getModel ( ) . getValueAt ( row , 0 ) ;
Object value = jTableProperties . getModel ( ) . getValueAt ( row , 1 ) ;
@Override
try {
public void tableChanged ( TableModelEvent evt ) {
Field field = config . lastUsedKey . getClass ( ) . getDeclaredField ( name ) ;
if ( evt . getType ( ) = = TableModelEvent . UPDATE ) {
field . setAccessible ( true ) ;
BlenderKeyConfiguration config = ConfigDialog . this . blenderKeyConfiguration ;
field . set ( config . lastUsedKey , value ) ;
int row = evt . getFirstRow ( ) ;
} catch ( IllegalArgumentException e ) {
String name = ( String ) jTableProperties . getModel ( ) . getValueAt ( row , 0 ) ;
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
Object value = jTableProperties . getModel ( ) . getValueAt ( row , 1 ) ;
} catch ( SecurityException e ) {
try {
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
Field field = config . lastUsedKey . getClass ( ) . getDeclaredField ( name ) ;
} catch ( IllegalAccessException e ) {
field . setAccessible ( true ) ;
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
field . set ( config . lastUsedKey , value ) ;
} catch ( NoSuchFieldException e ) {
} catch ( IllegalArgumentException e ) {
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
}
} catch ( SecurityException e ) {
}
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
}
} catch ( IllegalAccessException e ) {
} ) ;
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
jTableAnimations . getModel ( ) . addTableModelListener ( new TableModelListener ( ) {
} catch ( NoSuchFieldException e ) {
@Override
LOGGER . log ( Level . SEVERE , e . getMessage ( ) , e ) ;
public void tableChanged ( TableModelEvent evt ) {
}
if ( evt . getType ( ) = = TableModelEvent . INSERT ) {
}
jButtonRemoveAnimation . setEnabled ( true ) ;
}
} else if ( evt . getType ( ) = = TableModelEvent . DELETE & & jTableAnimations . getModel ( ) . getRowCount ( ) = = 0 ) {
} ) ;
jButtonRemoveAnimation . setEnabled ( false ) ;
jTableAnimations . getModel ( ) . addTableModelListener ( new TableModelListener ( ) {
}
}
@Override
} ) ;
public void tableChanged ( TableModelEvent evt ) {
jButtonAddAnimation . addActionListener ( new ActionListener ( ) {
if ( evt . getType ( ) = = TableModelEvent . INSERT ) {
@Override
jButtonRemoveAnimation . setEnabled ( true ) ;
public void actionPerformed ( ActionEvent evt ) {
} else if ( evt . getType ( ) = = TableModelEvent . DELETE & & jTableAnimations . getModel ( ) . getRowCount ( ) = = 0 ) {
( ( DefaultTableModel ) jTableAnimations . getModel ( ) ) . addRow ( new Object [ ] { "" , "" , Integer . valueOf ( - 1 ) , Integer . valueOf ( - 1 ) } ) ;
jButtonRemoveAnimation . setEnabled ( false ) ;
}
}
} ) ;
}
jButtonRemoveAnimation . addActionListener ( new ActionListener ( ) {
} ) ;
@Override
jButtonAddAnimation . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent evt ) {
int row = jTableAnimations . getSelectedRow ( ) ;
@Override
if ( row > = 0 ) {
public void actionPerformed ( ActionEvent evt ) {
( ( DefaultTableModel ) jTableAnimations . getModel ( ) ) . removeRow ( row ) ;
( ( DefaultTableModel ) jTableAnimations . getModel ( ) ) . addRow ( new Object [ ] { "" , "" , Integer . valueOf ( - 1 ) , Integer . valueOf ( - 1 ) } ) ;
}
}
}
} ) ;
} ) ;
jButtonRemoveAnimation . addActionListener ( new ActionListener ( ) {
//button listeners
@Override
jButtonOK . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent evt ) {
@Override
int row = jTableAnimations . getSelectedRow ( ) ;
public void actionPerformed ( ActionEvent evt ) {
if ( row > = 0 ) {
ConfigDialog . this . storeConfig ( blenderKeyConfiguration ) ;
( ( DefaultTableModel ) jTableAnimations . getModel ( ) ) . removeRow ( row ) ;
//running the test
}
SwingUtilities . invokeLater ( new Runnable ( ) {
}
@Override
} ) ;
public void run ( ) {
configExecutable . execute ( ConfigDialog . this . blenderKeyConfiguration . getKeyToUse ( ) ,
//button listeners
ConfigDialog . this . blenderKeyConfiguration . logLevel ) ;
jButtonOK . addActionListener ( new ActionListener ( ) {
}
} ) ;
@Override
//disposing the config window
public void actionPerformed ( ActionEvent evt ) {
ConfigDialog . this . dispose ( ) ;
ConfigDialog . this . storeConfig ( blenderKeyConfiguration ) ;
}
//running the test
} ) ;
SwingUtilities . invokeLater ( new Runnable ( ) {
jButtonCancel . addActionListener ( new ActionListener ( ) {
@Override
@Override
public void actionPerformed ( ActionEvent evt ) {
public void run ( ) {
ConfigDialog . this . dispose ( ) ;
configExecutable . execute ( ConfigDialog . this . blenderKeyConfiguration . getKeyToUse ( ) ,
}
ConfigDialog . this . blenderKeyConfiguration . logLevel ) ;
} ) ;
}
}
} ) ;
//disposing the config window
/ * *
ConfigDialog . this . dispose ( ) ;
* This class holds the configuration for all the files .
}
* It can be saved and loaded using jme mechanisms .
} ) ;
* @author Marcin Roguski ( Kaelthas )
jButtonCancel . addActionListener ( new ActionListener ( ) {
* /
public static class BlenderKeyConfiguration implements Savable {
@Override
private Map < String , BlenderKey > blenderKeys ;
public void actionPerformed ( ActionEvent evt ) {
private BlenderKey lastUsedKey ;
ConfigDialog . this . dispose ( ) ;
private Level logLevel ;
}
private boolean useModelKey ;
} ) ;
}
/ * *
* Constructor for jme serialization .
/ * *
* /
* This class holds the configuration for all the files .
public BlenderKeyConfiguration ( ) { }
* It can be saved and loaded using jme mechanisms .
* @author Marcin Roguski ( Kaelthas )
/ * *
* /
* Constructor that creates new empty configuration for every blender file .
public static class BlenderKeyConfiguration implements Savable {
* @param blenderFilesAmount the amount of blender files
* /
private Map < String , BlenderKey > blenderKeys ;
public BlenderKeyConfiguration ( int blenderFilesAmount ) {
private BlenderKey lastUsedKey ;
blenderKeys = new HashMap < String , BlenderKey > ( blenderFilesAmount ) ;
private Level logLevel ;
}
private boolean useModelKey ;
/ * *
/ * *
* This method returns the key that will be used during the test .
* Constructor for jme serialization .
* @return the key that will be used during the test
* /
* /
public BlenderKeyConfiguration ( ) {
public ModelKey getKeyToUse ( ) {
}
return useModelKey ? new ModelKey ( lastUsedKey . getName ( ) ) : lastUsedKey ;
}
/ * *
* Constructor that creates new empty configuration for every blender file .
@Override
* @param blenderFilesAmount the amount of blender files
public void write ( JmeExporter ex ) throws IOException {
* /
OutputCapsule oc = ex . getCapsule ( this ) ;
public BlenderKeyConfiguration ( int blenderFilesAmount ) {
oc . writeStringSavableMap ( blenderKeys , "keys" , null ) ;
blenderKeys = new HashMap < String , BlenderKey > ( blenderFilesAmount ) ;
oc . write ( lastUsedKey , "last-key" , null ) ;
}
oc . write ( useModelKey , "use-model-key" , false ) ;
oc . write ( logLevel = = null ? null : logLevel . getName ( ) , "log-level" , Level . INFO . getName ( ) ) ;
/ * *
}
* This method returns the key that will be used during the test .
* @return the key that will be used during the test
@Override
* /
@SuppressWarnings ( "unchecked" )
public ModelKey getKeyToUse ( ) {
public void read ( JmeImporter im ) throws IOException {
return useModelKey ? new ModelKey ( lastUsedKey . getName ( ) ) : lastUsedKey ;
InputCapsule ic = im . getCapsule ( this ) ;
}
blenderKeys = ( Map < String , BlenderKey > ) ic . readStringSavableMap ( "keys" , null ) ;
lastUsedKey = ( BlenderKey ) ic . readSavable ( "last-key" , null ) ;
@Override
useModelKey = ic . readBoolean ( "use-model-key" , false ) ;
public void write ( JmeExporter ex ) throws IOException {
String logLevelName = ic . readString ( "log-level" , Level . INFO . getName ( ) ) ;
OutputCapsule oc = ex . getCapsule ( this ) ;
logLevel = logLevelName = = null ? Level . INFO : Level . parse ( logLevelName ) ;
oc . writeStringSavableMap ( blenderKeys , "keys" , null ) ;
}
oc . write ( lastUsedKey , "last-key" , null ) ;
}
oc . write ( useModelKey , "use-model-key" , false ) ;
oc . write ( logLevel = = null ? null : logLevel . getName ( ) , "log-level" , Level . INFO . getName ( ) ) ;
}
@Override
@SuppressWarnings ( "unchecked" )
public void read ( JmeImporter im ) throws IOException {
InputCapsule ic = im . getCapsule ( this ) ;
blenderKeys = ( Map < String , BlenderKey > ) ic . readStringSavableMap ( "keys" , null ) ;
lastUsedKey = ( BlenderKey ) ic . readSavable ( "last-key" , null ) ;
useModelKey = ic . readBoolean ( "use-model-key" , false ) ;
String logLevelName = ic . readString ( "log-level" , Level . INFO . getName ( ) ) ;
logLevel = logLevelName = = null ? Level . INFO : Level . parse ( logLevelName ) ;
}
}
}
}