Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'ols_v0_9_6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Willem Janssen committed Aug 18, 2012
2 parents 8a662f5 + 6951af6 commit e47afd5
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 31 deletions.
Expand Up @@ -115,8 +115,10 @@ else if ( ExportFormat.CSV.equals( aFormat ) )
@Override
public void readPreferences( final UserSettings aSettings )
{
// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.owLine, aSettings, "owLine" );

this.owMode.setSelectedIndex( aSettings.getInt( "owMode", this.owMode.getSelectedIndex() ) );
this.owLine.setSelectedIndex( aSettings.getInt( "owLine", this.owLine.getSelectedIndex() ) );
}

/**
Expand Down
Expand Up @@ -135,13 +135,15 @@ else if ( ExportFormat.HTML.equals( aFormat ) )
*/
public void readPreferences( final UserSettings aSettings )
{
this.lineSMC.setSelectedIndex( aSettings.getInt( "lineSMC", this.lineSMC.getSelectedIndex() ) );
this.lineSTM.setSelectedIndex( aSettings.getInt( "lineSTM", this.lineSTM.getSelectedIndex() ) );
this.lineEBG.setSelectedIndex( aSettings.getInt( "lineEBG", this.lineEBG.getSelectedIndex() ) );
this.lineBYTE.setSelectedIndex( aSettings.getInt( "lineBYTE", this.lineBYTE.getSelectedIndex() ) );
this.lineBL.setSelectedIndex( aSettings.getInt( "lineBL", this.lineBL.getSelectedIndex() ) );
this.lineWRT.setSelectedIndex( aSettings.getInt( "lineWRT", this.lineWRT.getSelectedIndex() ) );
this.lineSYNC.setSelectedIndex( aSettings.getInt( "lineSYNC", this.lineSYNC.getSelectedIndex() ) );
// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.lineSMC, aSettings, "lineSMC" );
setComboBoxIndex( this.lineSTM, aSettings, "lineSTM" );
setComboBoxIndex( this.lineEBG, aSettings, "lineEBG" );
setComboBoxIndex( this.lineBYTE, aSettings, "lineBYTE" );
setComboBoxIndex( this.lineBL, aSettings, "lineBL" );
setComboBoxIndex( this.lineWRT, aSettings, "lineWRT" );
setComboBoxIndex( this.lineSYNC, aSettings, "lineSYNC" );

this.showInst.setSelected( aSettings.getBoolean( "showInst", this.showInst.isSelected() ) );
this.showData.setSelected( aSettings.getBoolean( "showData", this.showData.isSelected() ) );
this.showBusGrants.setSelected( aSettings.getBoolean( "showBusGrants", this.showBusGrants.isSelected() ) );
Expand Down
Expand Up @@ -26,6 +26,7 @@

import javax.swing.*;

import nl.lxtreme.ols.api.*;
import nl.lxtreme.ols.api.Configurable;
import nl.lxtreme.ols.api.acquisition.*;
import nl.lxtreme.ols.api.task.*;
Expand Down Expand Up @@ -384,6 +385,22 @@ protected void prepareToolTask( final ToolTask<RESULT_TYPE> aToolTask )
// NO-op
}

/**
* Convenience method to set the combobox index to a "safe" value, based on
* the given user settings.
*
* @param aComboBox
* the combobox to set the selected index for;
* @param aSettings
* the user settings to take the selected index from;
* @param aSettingName
* the name of the user setting to use.
*/
protected final void setComboBoxIndex( final JComboBox aComboBox, final UserSettings aSettings, final String aSettingName )
{
ToolUtils.setComboBoxIndex( aComboBox, aSettings.getInt( aSettingName, -1 ) );
}

/**
* set the controls of the dialog enabled/disabled
*
Expand Down
18 changes: 18 additions & 0 deletions tool.base/src/main/java/nl/lxtreme/ols/tool/base/ToolUtils.java
Expand Up @@ -263,6 +263,24 @@ public static JButton createRunAnalysisButton( final ToolDialog aToolDialog )
return runButton;
}

/**
* @param aComboBox
* @param aIndex
*/
public static void setComboBoxIndex( final JComboBox aComboBox, final int aIndex )
{
int idx = aIndex;
if ( idx < 0 )
{
idx = aComboBox.getSelectedIndex();
}
else if ( idx > aComboBox.getItemCount() )
{
idx = idx % aComboBox.getItemCount();
}
aComboBox.setSelectedIndex( idx );
}

/**
* Convenience method to show an error message.
*
Expand Down
Expand Up @@ -117,7 +117,8 @@ else if ( ExportFormat.CSV.equals( aFormat ) )
@Override
public void readPreferences( final UserSettings aSettings )
{
this.dataLine.setSelectedIndex( aSettings.getInt( "dataLine", this.dataLine.getSelectedIndex() ) );
// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.dataLine, aSettings, "dataLine" );
}

/**
Expand Down
Expand Up @@ -167,8 +167,9 @@ else if ( I2CAnalyserTask.LINE_B.equals( lineValue ) )
*/
public void readPreferences( final UserSettings aSettings )
{
this.lineA.setSelectedIndex( aSettings.getInt( "lineA", this.lineA.getSelectedIndex() ) );
this.lineB.setSelectedIndex( aSettings.getInt( "lineB", this.lineB.getSelectedIndex() ) );
// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.lineA, aSettings, "lineA" );
setComboBoxIndex( this.lineB, aSettings, "lineB" );

this.detectSDA_SCL.setSelected( aSettings.getBoolean( "detectSDA_SCL", this.detectSDA_SCL.isSelected() ) );
this.detectSTART.setSelected( aSettings.getBoolean( "detectStart", this.detectSTART.isSelected() ) );
Expand Down
Expand Up @@ -120,10 +120,11 @@ else if ( ExportFormat.CSV.equals( aFormat ) )
*/
public void readPreferences( final UserSettings aSettings )
{
this.tck.setSelectedIndex( aSettings.getInt( "tck", this.tck.getSelectedIndex() ) );
this.tms.setSelectedIndex( aSettings.getInt( "tms", this.tms.getSelectedIndex() ) );
this.tdi.setSelectedIndex( aSettings.getInt( "tdi", this.tdi.getSelectedIndex() ) );
this.tdo.setSelectedIndex( aSettings.getInt( "tdo", this.tdo.getSelectedIndex() ) );
// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.tck, aSettings, "tck" );
setComboBoxIndex( this.tms, aSettings, "tms" );
setComboBoxIndex( this.tdi, aSettings, "tdi" );
setComboBoxIndex( this.tdo, aSettings, "tdo" );
}

/**
Expand Down
Expand Up @@ -126,7 +126,8 @@ public void readPreferences( final UserSettings aSettings )

for ( int i = 0; i < this.lines.length; i++ )
{
this.lines[i].setSelectedIndex( aSettings.getInt( "decoder.line." + i, this.lines[i].getSelectedIndex() ) );
// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.lines[i], aSettings, "decoder.line." + i );
}
}

Expand Down
Expand Up @@ -287,12 +287,15 @@ public void readPreferences( final UserSettings aSettings )
this.spifiMode.setSelectedIndex( aSettings.getInt( "protocol", this.spifiMode.getSelectedIndex() ) );
this.reportCS.setSelected( aSettings.getBoolean( "reportCS", this.reportCS.isSelected() ) );
this.honourCS.setSelected( aSettings.getBoolean( "honourCS", this.honourCS.isSelected() ) );
this.sck.setSelectedIndex( aSettings.getInt( "sck", this.sck.getSelectedIndex() ) );
this.miso.setSelectedIndex( aSettings.getInt( "miso", this.miso.getSelectedIndex() ) );
this.mosi.setSelectedIndex( aSettings.getInt( "mosi", this.mosi.getSelectedIndex() ) );
this.io2.setSelectedIndex( aSettings.getInt( "io2", this.io2.getSelectedIndex() ) );
this.io3.setSelectedIndex( aSettings.getInt( "io3", this.io3.getSelectedIndex() ) );
this.cs.setSelectedIndex( aSettings.getInt( "cs", this.cs.getSelectedIndex() ) );

// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.sck, aSettings, "sck" );
setComboBoxIndex( this.miso, aSettings, "miso" );
setComboBoxIndex( this.mosi, aSettings, "mosi" );
setComboBoxIndex( this.io2, aSettings, "io2" );
setComboBoxIndex( this.io3, aSettings, "io3" );
setComboBoxIndex( this.cs, aSettings, "cs" );

this.mode.setSelectedIndex( aSettings.getInt( "mode", this.mode.getSelectedIndex() ) );
this.bits.setSelectedIndex( aSettings.getInt( "bits", this.bits.getSelectedIndex() ) );
this.order.setSelectedIndex( aSettings.getInt( "order", this.order.getSelectedIndex() ) );
Expand Down
Expand Up @@ -122,8 +122,10 @@ public StateAnalysisDialog( final Window aOwner, final ToolContext aToolContext,
@Override
public void readPreferences( final UserSettings aSettings )
{
// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.channelSelect, aSettings, "channel" );

this.edgeSelect.setSelectedIndex( aSettings.getInt( "edge", this.edgeSelect.getSelectedIndex() ) );
this.channelSelect.setSelectedIndex( aSettings.getInt( "channel", this.channelSelect.getSelectedIndex() ) );
}

/**
Expand Down
Expand Up @@ -211,14 +211,16 @@ else if ( ExportFormat.CSV.equals( aFormat ) )
@Override
public void readPreferences( final UserSettings aSettings )
{
this.rxd.setSelectedIndex( aSettings.getInt( "rxd", this.rxd.getSelectedIndex() ) );
this.txd.setSelectedIndex( aSettings.getInt( "txd", this.txd.getSelectedIndex() ) );
this.cts.setSelectedIndex( aSettings.getInt( "cts", this.cts.getSelectedIndex() ) );
this.rts.setSelectedIndex( aSettings.getInt( "rts", this.rts.getSelectedIndex() ) );
this.dtr.setSelectedIndex( aSettings.getInt( "dtr", this.dtr.getSelectedIndex() ) );
this.dsr.setSelectedIndex( aSettings.getInt( "dsr", this.dsr.getSelectedIndex() ) );
this.dcd.setSelectedIndex( aSettings.getInt( "dcd", this.dcd.getSelectedIndex() ) );
this.ri.setSelectedIndex( aSettings.getInt( "ri", this.ri.getSelectedIndex() ) );
// Issue #114: avoid setting illegal values...
setComboBoxIndex( this.rxd, aSettings, "rxd" );
setComboBoxIndex( this.txd, aSettings, "txd" );
setComboBoxIndex( this.cts, aSettings, "cts" );
setComboBoxIndex( this.rts, aSettings, "rts" );
setComboBoxIndex( this.dtr, aSettings, "dtr" );
setComboBoxIndex( this.dsr, aSettings, "dsr" );
setComboBoxIndex( this.dcd, aSettings, "dcd" );
setComboBoxIndex( this.ri, aSettings, "ri" );

this.parity.setSelectedIndex( aSettings.getInt( "parity", this.parity.getSelectedIndex() ) );
this.bits.setSelectedIndex( aSettings.getInt( "bits", this.bits.getSelectedIndex() ) );
this.stop.setSelectedIndex( aSettings.getInt( "stop", this.stop.getSelectedIndex() ) );
Expand Down

0 comments on commit e47afd5

Please sign in to comment.