Skip to content

Commit b667337

Browse files
authored
Merge pull request #330 from bls337/main
resolve some TODOs with the channel table
2 parents ac3a24a + bb7f78e commit b667337

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

src/main/java/org/micromanager/lightsheetmanager/gui/tabs/channels/ChannelTable.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import java.util.ArrayList;
1616
import java.util.Objects;
1717

18+
/**
19+
* This is the JTable ui element for channel settings.
20+
*/
1821
public class ChannelTable extends JScrollPane {
1922

2023
private JTable table_;
@@ -39,11 +42,9 @@ public ChannelTable(final LightSheetManager model) {
3942
TableColumn column = table_.getColumnModel().getColumn(1);
4043
cmbPresets_ = new JComboBox<>();
4144

42-
final String[] presets = getAllPresets(channelGroup);
43-
for (String preset : presets) {
44-
cmbPresets_.addItem(preset);
45-
}
46-
//cmbPresets_.setSelectedItem(presets[0]);
45+
// update presets
46+
updatePresetComboBoxes(channelGroup);
47+
4748
column.setCellEditor(new DefaultCellEditor(cmbPresets_));
4849

4950
// cancel JTable edits when focus is lost to prevent errors
@@ -88,26 +89,22 @@ public JTable getTable() {
8889
*
8990
* @param channelGroup the channel group
9091
*/
91-
public void updatePresetComboBox(final String channelGroup) {
92-
final String[] presets = getAllPresets(channelGroup);
92+
public void updatePresetComboBoxes(final String channelGroup) {
93+
final String[] presets = getChannelGroupPresets(channelGroup);
9394
cmbPresets_.removeAllItems();
9495
for (String preset : presets) {
9596
cmbPresets_.addItem(preset);
9697
}
9798
cmbPresets_.setSelectedItem(channelGroup);
9899
}
99100

100-
// public void updateAvailableChannelConfigs(final String channelGroup) {
101-
//
102-
// }
103-
104101
// TODO: probably should be in the model
105-
private String[] getAllPresets(final String configGroup) {
102+
private String[] getChannelGroupPresets(final String configGroup) {
106103
return model_.studio().core().getAvailableConfigs(configGroup).toArray();
107104
}
108105

109106
// TODO: probably should be in the model
110-
public String[] getAvailableGroups() {
107+
public String[] getChannelGroups() {
111108
// get all channel groups
112109
StrVector channelGroups;
113110
try {
@@ -120,13 +117,13 @@ public String[] getAvailableGroups() {
120117
// filter channel groups
121118
ArrayList<String> groups = new ArrayList<>();
122119
for (String group : channelGroups) {
123-
// StrVector st = model_.studio().core().getAvailableConfigGroups();
124-
// for (String s : st)
125-
// System.out.println(s);
126120
// a channel group must have multiple presets to be detected
127121
if (model_.studio().core().getAvailableConfigs(group).size() > 1) {
128122
groups.add(group);
129123
}
124+
// StrVector st = model_.studio().core().getAvailableConfigGroups();
125+
// for (String s : st)
126+
// System.out.println(s);
130127
}
131128
return groups.toArray(String[]::new);
132129
}

src/main/java/org/micromanager/lightsheetmanager/gui/tabs/channels/ChannelTableModel.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ public Object getValueAt(int row, int col) {
5757
case 2:
5858
return channelSpec.getOffset();
5959
default:
60-
return null; // FIXME: is this okay? raise exception?
60+
throw new IllegalArgumentException("Invalid column index: " + col);
6161
}
6262
}
6363

64-
// TODO: is if (value instanceof Boolean) { needed?
65-
6664
@Override
6765
public void setValueAt(Object value, int row, int col) {
6866
ChannelSpec channelSpec = tableData_.getChannelByIndex(row);
@@ -83,8 +81,7 @@ public void setValueAt(Object value, int row, int col) {
8381
}
8482
break;
8583
default:
86-
// FIXME: is this okay? raise exception?
87-
break;
84+
throw new IllegalArgumentException("Invalid column index: " + col);
8885
}
8986
fireTableCellUpdated(row, col);
9087
}

src/main/java/org/micromanager/lightsheetmanager/gui/tabs/channels/ChannelTablePanel.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import javax.swing.JLabel;
1212
import java.util.Objects;
1313

14+
/**
15+
* This panel contains the ChannelTable and controls.
16+
*/
1417
public class ChannelTablePanel extends Panel {
1518

1619
private JLabel lblChannelGroup_;
@@ -47,7 +50,7 @@ private void createUserInterface() {
4750
btnRemoveChannel_.setToolTipText("Remove the currently selected channel from the table.");
4851
btnRefresh_.setToolTipText("Refresh the channel panel with the latest configuration groups settings.");
4952

50-
final String[] groupLabels = table_.getAvailableGroups();
53+
final String[] groupLabels = table_.getChannelGroups();
5154
cmbChannelGroup_ = new ComboBox(groupLabels,
5255
model_.acquisitions().settings().channelGroup(),
5356
120, 22);
@@ -71,7 +74,7 @@ private void createEventHandlers() {
7174
// select channel group
7275
cmbChannelGroup_.registerListener(e -> {
7376
final String channelGroup = cmbChannelGroup_.getSelected();
74-
table_.updatePresetComboBox(channelGroup);
77+
table_.updatePresetComboBoxes(channelGroup);
7578
table_.getData().setChannels(channelGroup, model_.acquisitions().settings().channels());
7679
table_.getData().setChannelGroup(channelGroup);
7780
model_.acquisitions().settingsBuilder().channelGroup(channelGroup);
@@ -108,7 +111,7 @@ private void createEventHandlers() {
108111
// refresh channel table
109112
btnRefresh_.registerListener(e -> {
110113
final String channelGroup = model_.acquisitions().settings().channelGroup();
111-
final String[] groups = table_.getAvailableGroups();
114+
final String[] groups = table_.getChannelGroups();
112115
cmbChannelGroup_.removeAllItems();
113116
for (String group : groups) {
114117
cmbChannelGroup_.addItem(group);
@@ -117,7 +120,7 @@ private void createEventHandlers() {
117120
cmbChannelGroup_.setSelectedItem(channelGroup);
118121
}
119122
}
120-
table_.updatePresetComboBox(channelGroup);
123+
table_.updatePresetComboBoxes(channelGroup);
121124
cmbChannelGroup_.updateUI();
122125
});
123126

src/main/java/org/micromanager/lightsheetmanager/model/channels/ChannelTableData.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.micromanager.lightsheetmanager.model.channels;
22

33
import java.util.ArrayList;
4-
import java.util.Collections;
54

65
/**
76
* The data model's internal representation of the channel table.
@@ -19,8 +18,6 @@ public ChannelTableData() {
1918
public ChannelTableData(final String channelGroup, final ChannelSpec[] allChannels) {
2019
channels_ = new ArrayList<>();
2120
setChannels(channelGroup, allChannels);
22-
//channelGroup_ = channelGroup;
23-
//Collections.addAll(channels_, allChannels);
2421
}
2522

2623
public ChannelSpec getChannelByIndex(final int index) {

0 commit comments

Comments
 (0)