Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,13 @@ private void createUserInterface() {
Button.setDefaultSize(140, 30);
btnRunOverviewAcq_ = new Button("Overview Acquisition");

cbxUseChannels_ = new CheckBox(
"Channels", acqSettings.isUsingChannels());
final boolean isUsingChannels = acqSettings.isUsingChannels();
cbxUseChannels_ = new CheckBox("Channels", isUsingChannels);
pnlChannelTable_ = new ChannelTablePanel(model_, cbxUseChannels_);
pnlChannelTable_.setMaximumSize(new Dimension(270, 400));

// disable elements based on acqSettings
if (!acqSettings.isUsingChannels()) {
pnlChannelTable_.setItemsEnabled(false);
}
pnlChannelTable_.setItemsEnabled(isUsingChannels);

// acquisition mode combo box
final boolean isUsingScanSettings = model_.devices().isUsingStageScanning();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ public ChannelTable(final LightSheetManager model) {
table_ = new JTable(tableModel_);

// init presets combo box
TableColumn column = table_.getColumnModel().getColumn(1);
cmbPresets_ = new JComboBox<>();

// update presets
updatePresetComboBoxes(channelGroup);

// set the editor
TableColumn column = table_.getColumnModel().getColumn(1);
column.setCellEditor(new DefaultCellEditor(cmbPresets_));

// cancel JTable edits when focus is lost to prevent errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

public class ChannelTableModel extends AbstractTableModel {

// column constants
private static final int COLUMN_USE = 0;
private static final int COLUMN_PRESET = 1;
private static final int COLUMN_OFFSET = 2;

/**Column names for the channels table. */
private final String[] columnNames_ = {
"Use",
Expand All @@ -27,13 +32,23 @@ public int getRowCount() {
}

@Override
public Class<?> getColumnClass(int c) {
return getValueAt(0, c).getClass();
public int getColumnCount() {
return columnNames_.length;
}

@Override
public int getColumnCount() {
return columnNames_.length;
public Class<?> getColumnClass(int c) {
switch (c) {
case COLUMN_USE:
return Boolean.class;
case COLUMN_PRESET:
return String.class;
case COLUMN_OFFSET:
return Double.class;
default:
// Note: This will never happen if getColumnCount is correct.
throw new IllegalArgumentException("Invalid column index: " + c);
}
}

@Override
Expand All @@ -48,13 +63,13 @@ public boolean isCellEditable(int row, int col) {

@Override
public Object getValueAt(int row, int col) {
ChannelSpec channelSpec = tableData_.getChannelByIndex(row);
final ChannelSpec channelSpec = tableData_.getChannelByIndex(row);
switch (col) {
case 0:
case COLUMN_USE:
return channelSpec.isUsed();
case 1:
case COLUMN_PRESET:
return channelSpec.getName();
case 2:
case COLUMN_OFFSET:
return channelSpec.getOffset();
default:
throw new IllegalArgumentException("Invalid column index: " + col);
Expand All @@ -63,26 +78,34 @@ public Object getValueAt(int row, int col) {

@Override
public void setValueAt(Object value, int row, int col) {
ChannelSpec channelSpec = tableData_.getChannelByIndex(row);
final ChannelSpec channelSpec = tableData_.getChannelByIndex(row);
switch (col) {
case 0:
case COLUMN_USE:
if (value instanceof Boolean) {
channelSpec.setUsed((boolean) value);
} else {
return; // early exit => wrong type
}
break;
case 1:
case COLUMN_PRESET:
if (value instanceof String) {
channelSpec.setName((String) value);
} else {
return; // early exit => wrong type
}
break;
case 2:
case COLUMN_OFFSET:
if (value instanceof Double) {
channelSpec.setOffset((double) value);
} else {
return; // early exit => wrong type
}
break;
default:
throw new IllegalArgumentException("Invalid column index: " + col);
}

// update the table ui
fireTableCellUpdated(row, col);
}

Expand Down
Loading