final OSCRoot osc;
final PrefCacheManager cm;
final Flag haveWarned = new Flag( false );
final String txtWarnLookAndFeel = getResourceString( "warnLookAndFeelUpdate" );
final TreeExpanderButton ggTreeAudio;
final List collAudioAdvanced;
SpringPanel tab;
PrefParamField ggParam;
BasicPathField ggPath;
PrefCheckBox ggCheckBox;
PrefComboBox ggChoice;
JTabbedPane ggTabPane;
JLabel lb;
JComboBox ggCombo;
UIManager.LookAndFeelInfo[] lafInfos;
Box b;
Preferences prefs;
String key, key2, title;
int row;
ggTabPane = new JTabbedPane();
// ---------- global pane ----------
tab = createTab();
row = 0;
prefs = IOUtil.getUserPrefs();
key = IOUtil.KEY_TEMPDIR;
key2 = "prefsTmpDir";
lb = new JLabel( getResourceString( key2 ), TRAILING );
tab.gridAdd( lb, 0, row );
ggPath = new BasicPathField( PathField.TYPE_FOLDER, getResourceString( key2 ));
ggPath.setPreferences( prefs, key );
tab.gridAdd( ggPath, 1, row );
row++;
cm = PrefCacheManager.getInstance();
prefs = cm.getPreferences();
key = PrefCacheManager.KEY_ACTIVE;
key2 = "prefsCache";
lb = new JLabel( getResourceString( key2 ), TRAILING );
tab.gridAdd( lb, 0, row );
ggCheckBox = new PrefCheckBox( getResourceString( "prefsCacheActive" ));
ggCheckBox.setPreferences( prefs, key );
// tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
b = Box.createHorizontalBox();
b.add( ggCheckBox );
//
// row++;
key = PrefCacheManager.KEY_CAPACITY;
key2 = "prefsCacheCapacity";
lb = new JLabel( getResourceString( key2 ) + " [" +
getResourceString( "labelMegaBytes" ) + "]", TRAILING );
// tab.gridAdd( lb, 0, row );
b.add( Box.createHorizontalStrut( 16 ));
b.add( lb );
ggParam = new PrefParamField();
ggParam.addSpace( spcIntegerFromOne );
ggParam.setPreferences( prefs, key );
// tab.gridAdd( ggParam, 1, row, -1, 1 );
b.add( ggParam );
tab.gridAdd( b, 1, row, -1, 1 );
row++;
key = PrefCacheManager.KEY_FOLDER;
key2 = "prefsCacheFolder";
lb = new JLabel( getResourceString( key2 ), TRAILING );
tab.gridAdd( lb, 0, row );
ggPath = new BasicPathField( PathField.TYPE_FOLDER, getResourceString( key2 ));
ggPath.setPreferences( prefs, key );
tab.gridAdd( ggPath, 1, row );
row++;
prefs = app.getUserPrefs();
key = PrefsUtil.KEY_LOOKANDFEEL;
key2 = "prefsLookAndFeel";
title = getResourceString( key2 );
lb = new JLabel( title, TRAILING );
tab.gridAdd( lb, 0, row );
ggChoice = new PrefComboBox();
lafInfos = UIManager.getInstalledLookAndFeels();
for( int i = 0; i < lafInfos.length; i++ ) {
ggChoice.addItem( new StringItem( lafInfos[i].getClassName(), lafInfos[i].getName() ));
}
ggChoice.setPreferences( prefs, key );
ggChoice.addActionListener( new WarnPrefsChange( ggChoice, ggChoice, haveWarned, txtWarnLookAndFeel, title ));
tab.gridAdd( ggChoice, 1, row, -1, 1 );
row++;
key = BasicWindowHandler.KEY_LAFDECORATION;
key2 = "prefsLAFDecoration";
title = getResourceString( key2 );
ggCheckBox = new PrefCheckBox( title );
ggCheckBox.setPreferences( prefs, key );
tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
ggCheckBox.addActionListener( new WarnPrefsChange( ggCheckBox, ggCheckBox, haveWarned, txtWarnLookAndFeel, title ));
row++;
key = BasicWindowHandler.KEY_INTERNALFRAMES;
key2 = "prefsInternalFrames";
title = getResourceString( key2 );
ggCheckBox = new PrefCheckBox( title );
ggCheckBox.setPreferences( prefs, key );
tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
ggCheckBox.addActionListener( new WarnPrefsChange( ggCheckBox, ggCheckBox, haveWarned, txtWarnLookAndFeel, title ));
row++;
key = CoverGrowBox.KEY_INTRUDINGSIZE;
key2 = "prefsIntrudingSize";
ggCheckBox = new PrefCheckBox( getResourceString( key2 ));
ggCheckBox.setPreferences( prefs, key );
tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
row++;
key = BasicWindowHandler.KEY_FLOATINGPALETTES;
key2 = "prefsFloatingPalettes";
ggCheckBox = new PrefCheckBox( getResourceString( key2 ));
ggCheckBox.setPreferences( prefs, key );
tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
ggCheckBox.addActionListener( new WarnPrefsChange( ggCheckBox, ggCheckBox, haveWarned, txtWarnLookAndFeel, title ));
// row++;
// prefs = GUIUtil.getUserPrefs();
// key2 = "prefsKeyStrokeHelp";
// lb = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
// tab.gridAdd( lb, 0, row );
// ggKeyStroke = new KeyStrokeTextField();
// ggKeyStroke.setPreferences( prefs, key );
// tab.gridAdd( ggKeyStroke, 1, row, -1, 1 );
addTab( ggTabPane, tab, "prefsGeneral");
// ---------- audio pane ----------
prefs = app.getUserPrefs().node( PrefsUtil.NODE_AUDIO );
audioPrefs = prefs;
abPrefs = audioPrefs.node( PrefsUtil.NODE_AUDIOBOXES );
tab = createTab();
row = 0;
key = PrefsUtil.KEY_SUPERCOLLIDERAPP;
key2 = "prefsSuperColliderApp";
lb = new JLabel( getResourceString( key2 ), TRAILING );
tab.gridAdd( lb, 0, row );
ggPath = new BasicPathField( PathField.TYPE_INPUTFILE, getResourceString( key2 ));
ggPath.setPreferences( prefs, key );
// HelpGlassPane.setHelp( ggPath, key2 );
tab.gridAdd( ggPath, 1, row );
// row++;
// key = PrefsUtil.KEY_SUPERCOLLIDEROSC;
// key2 = "prefsSuperColliderOSC";
// lb = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
// tab.gridAdd( lb, 0, row );
// ggText = new PrefTextField( 32 );
// ggText.setPreferences( prefs, key );
// tab.gridAdd( ggText, 1, row, -1, 1 );
row++;
key = PrefsUtil.KEY_AUTOBOOT;
key2 = "prefsAutoBoot";
// lb = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
// tab.gridAdd( lb, 0, row );
ggCheckBox = new PrefCheckBox( getResourceString( key2 ));
ggCheckBox.setPreferences( prefs, key );
// HelpGlassPane.setHelp( ggCheckBox, key2 );
tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
row++;
key = PrefsUtil.KEY_AUTOPLAYFROMFINDER;
key2 = "prefsAutoPlayFromFinder";
lb = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
tab.gridAdd( lb, 0, row );
ggChoice = new PrefComboBox();
ggChoice.addItem( new StringItem( PrefsUtil.AUTOPLAYFROMFINDER_NONE, getResourceString( key2 + "." + PrefsUtil.AUTOPLAYFROMFINDER_NONE )));
ggChoice.addItem( new StringItem( PrefsUtil.AUTOPLAYFROMFINDER_PLAY, getResourceString( key2 + "." + PrefsUtil.AUTOPLAYFROMFINDER_PLAY )));
ggChoice.addItem( new StringItem( PrefsUtil.AUTOPLAYFROMFINDER_LOOP, getResourceString( key2 + "." + PrefsUtil.AUTOPLAYFROMFINDER_LOOP )));
ggChoice.setPreferences( prefs, key );
tab.gridAdd( ggChoice, 1, row, -1, 1 );
row++;
lb = new JLabel( getResourceString( "labelAudioIFs" ), TRAILING );
tab.gridAdd( lb, 0, row );
tab.gridAdd( createAudioBoxGUI(), 1, row, 1, -1 );
row++;
key = PrefsUtil.KEY_AUDIORATE;
key2 = "prefsAudioRate";
lb = new JLabel( getResourceString( key2 ), TRAILING );
tab.gridAdd( lb, 0, row );
ggParam = new PrefParamField();
ggParam.addSpace( ParamSpace.spcFreqHertz );
ggCombo = new JComboBox();
for( int i = 0; i < RATE_ITEMS.length; i++ ) {
ggCombo.addItem( RATE_ITEMS[ i ]);
}
ggParam.setBorder( new ComboBoxEditorBorder() );
ggCombo.setEditor( ggParam );
ggCombo.setEditable( true );
ggParam.setPreferences( prefs, key ); // important to be _afer_ setEditor because otherwise prefs get overwritten!
// ggCombo.setSelectedIndex( 0 ); // DEFAULT_RATE
//ggParam.setPreferredSize( new Dimension( ggParam.getPreferredSize().width, Math.max( 24, ggParam.getPreferredSize().height )));
//ggCombo.setPreferredSize( new Dimension( ggCombo.getPreferredSize().width, Math.max( 24, ggCombo.getPreferredSize().height )));
tab.gridAdd( ggCombo, 1, row, -1, 1 );
row++;
b = Box.createHorizontalBox();
b.add( Box.createHorizontalGlue() );
ggTreeAudio = new TreeExpanderButton();
b.add( ggTreeAudio );
b.add( new JLabel( getResourceString( "prefsAdvanced" )));
tab.gridAdd( b, 0, row );
collAudioAdvanced = new ArrayList();
row++;
key2 = "prefsSuperColliderOSC";
lb = new JLabel( getResourceString( key2 ), TRAILING );
lb.setVisible( false );
collAudioAdvanced.add( lb );
tab.gridAdd( lb, 0, row );
key = PrefsUtil.KEY_SCPROTOCOL;
key2 = "prefsOSCProtocol";
lb = new JLabel( getResourceString( key2 ), TRAILING );
// tab.gridAdd( lb, 2, row );
b = Box.createHorizontalBox();
b.add( Box.createHorizontalStrut( 4 ));
b.add( lb );
ggChoice = new PrefComboBox();
ggChoice.addItem( new StringItem( OSCChannel.TCP, "TCP" ));
ggChoice.addItem( new StringItem( OSCChannel.UDP, "UDP" ));
ggChoice.setPreferences( prefs, key );
// tab.gridAdd( ggChoice, 3, row, -1, 1 );
b.add( ggChoice );
key = PrefsUtil.KEY_SCPORT;
key2 = "prefsOSCPort";
lb = new JLabel( getResourceString( key2 ), TRAILING );
// tab.gridAdd( lb, 4, row );
b.add( Box.createHorizontalStrut( 16 ));
b.add( lb );
ggParam = new PrefParamField();
ggParam.addSpace( spcIntegerFromZero );
ggParam.setPreferences( prefs, key );
// tab.gridAdd( ggParam, 5, row, -1, 1 );
b.add( ggParam );
b.setVisible( false );
collAudioAdvanced.add( b );
tab.gridAdd( b, 1, row, -1, 1 );
row++;
key = PrefsUtil.KEY_SCBLOCKSIZE;
key2 = "prefsSCBlockSize";
lb = new JLabel( getResourceString( key2 ), TRAILING );
lb.setVisible( false );
collAudioAdvanced.add( lb );
tab.gridAdd( lb, 0, row );
ggParam = new PrefParamField();
ggParam.addSpace( spcIntegerFromOne );
ggParam.setPreferences( prefs, key );
ggParam.setVisible( false );
collAudioAdvanced.add( ggParam );
tab.gridAdd( ggParam, 1, row, -1, 1 );
row++;
key = PrefsUtil.KEY_AUDIOBUSSES;
key2 = "prefsAudioBusses";
lb = new JLabel( getResourceString( key2 ), TRAILING );
lb.setVisible( false );
collAudioAdvanced.add( lb );
tab.gridAdd( lb, 0, row );
ggParam = new PrefParamField();
ggParam.addSpace( spcIntegerFromOne );
ggParam.setPreferences( prefs, key );
ggParam.setVisible( false );
collAudioAdvanced.add( ggParam );
tab.gridAdd( ggParam, 1, row, -1, 1 );
// pAudio.makeCompactGrid();
// pAudio.setVisible( false );
row++;
key = PrefsUtil.KEY_SCMEMSIZE;
key2 = "prefsSCMemSize";
lb = new JLabel( getResourceString( key2 ), TRAILING );
lb.setVisible( false );
collAudioAdvanced.add( lb );
tab.gridAdd( lb, 0, row );
ggParam = new PrefParamField();
ggParam.addSpace( spcIntegerFromOne );
ggParam.setPreferences( prefs, key );
ggParam.setVisible( false );
collAudioAdvanced.add( ggParam );
tab.gridAdd( ggParam, 1, row, -1, 1 );
row++;
key = PrefsUtil.KEY_SCRENDEZVOUS;
key2 = "prefsSCRendezvous";
lb = new JLabel( getResourceString( key2 ), TRAILING );
lb.setVisible( false );
collAudioAdvanced.add( lb );
tab.gridAdd( lb, 0, row );
ggCheckBox = new PrefCheckBox();
ggCheckBox.setPreferences( prefs, key );
ggCheckBox.setVisible( false );
collAudioAdvanced.add( ggCheckBox );
tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
final SpringPanel tabAudio = tab;
ggTreeAudio.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e )
{
final int width = getWindow().getWidth();
final int height = getWindow().getHeight();
final boolean visible = ggTreeAudio.isExpanded();
int delta = 0;
int d2;
for( int i = 0; i < collAudioAdvanced.size(); ) {
d2 = 0;