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 @@ -15,6 +15,9 @@
import java.util.ArrayList;
import java.util.Objects;

/**
* This is the JTable ui element for channel settings.
*/
public class ChannelTable extends JScrollPane {

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

final String[] presets = getAllPresets(channelGroup);
for (String preset : presets) {
cmbPresets_.addItem(preset);
}
//cmbPresets_.setSelectedItem(presets[0]);
// update presets
updatePresetComboBoxes(channelGroup);

column.setCellEditor(new DefaultCellEditor(cmbPresets_));

// cancel JTable edits when focus is lost to prevent errors
Expand Down Expand Up @@ -88,26 +89,22 @@ public JTable getTable() {
*
* @param channelGroup the channel group
*/
public void updatePresetComboBox(final String channelGroup) {
final String[] presets = getAllPresets(channelGroup);
public void updatePresetComboBoxes(final String channelGroup) {
final String[] presets = getChannelGroupPresets(channelGroup);
cmbPresets_.removeAllItems();
for (String preset : presets) {
cmbPresets_.addItem(preset);
}
cmbPresets_.setSelectedItem(channelGroup);
}

// public void updateAvailableChannelConfigs(final String channelGroup) {
//
// }

// TODO: probably should be in the model
private String[] getAllPresets(final String configGroup) {
private String[] getChannelGroupPresets(final String configGroup) {
return model_.studio().core().getAvailableConfigs(configGroup).toArray();
}

// TODO: probably should be in the model
public String[] getAvailableGroups() {
public String[] getChannelGroups() {
// get all channel groups
StrVector channelGroups;
try {
Expand All @@ -120,13 +117,13 @@ public String[] getAvailableGroups() {
// filter channel groups
ArrayList<String> groups = new ArrayList<>();
for (String group : channelGroups) {
// StrVector st = model_.studio().core().getAvailableConfigGroups();
// for (String s : st)
// System.out.println(s);
// a channel group must have multiple presets to be detected
if (model_.studio().core().getAvailableConfigs(group).size() > 1) {
groups.add(group);
}
// StrVector st = model_.studio().core().getAvailableConfigGroups();
// for (String s : st)
// System.out.println(s);
}
return groups.toArray(String[]::new);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ public Object getValueAt(int row, int col) {
case 2:
return channelSpec.getOffset();
default:
return null; // FIXME: is this okay? raise exception?
throw new IllegalArgumentException("Invalid column index: " + col);
}
}

// TODO: is if (value instanceof Boolean) { needed?

@Override
public void setValueAt(Object value, int row, int col) {
ChannelSpec channelSpec = tableData_.getChannelByIndex(row);
Expand All @@ -83,8 +81,7 @@ public void setValueAt(Object value, int row, int col) {
}
break;
default:
// FIXME: is this okay? raise exception?
break;
throw new IllegalArgumentException("Invalid column index: " + col);
}
fireTableCellUpdated(row, col);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import javax.swing.JLabel;
import java.util.Objects;

/**
* This panel contains the ChannelTable and controls.
*/
public class ChannelTablePanel extends Panel {

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

final String[] groupLabels = table_.getAvailableGroups();
final String[] groupLabels = table_.getChannelGroups();
cmbChannelGroup_ = new ComboBox(groupLabels,
model_.acquisitions().settings().channelGroup(),
120, 22);
Expand All @@ -71,7 +74,7 @@ private void createEventHandlers() {
// select channel group
cmbChannelGroup_.registerListener(e -> {
final String channelGroup = cmbChannelGroup_.getSelected();
table_.updatePresetComboBox(channelGroup);
table_.updatePresetComboBoxes(channelGroup);
table_.getData().setChannels(channelGroup, model_.acquisitions().settings().channels());
table_.getData().setChannelGroup(channelGroup);
model_.acquisitions().settingsBuilder().channelGroup(channelGroup);
Expand Down Expand Up @@ -108,7 +111,7 @@ private void createEventHandlers() {
// refresh channel table
btnRefresh_.registerListener(e -> {
final String channelGroup = model_.acquisitions().settings().channelGroup();
final String[] groups = table_.getAvailableGroups();
final String[] groups = table_.getChannelGroups();
cmbChannelGroup_.removeAllItems();
for (String group : groups) {
cmbChannelGroup_.addItem(group);
Expand All @@ -117,7 +120,7 @@ private void createEventHandlers() {
cmbChannelGroup_.setSelectedItem(channelGroup);
}
}
table_.updatePresetComboBox(channelGroup);
table_.updatePresetComboBoxes(channelGroup);
cmbChannelGroup_.updateUI();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.micromanager.lightsheetmanager.model.channels;

import java.util.ArrayList;
import java.util.Collections;

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

public ChannelSpec getChannelByIndex(final int index) {
Expand Down
Loading