From 46bf3e16e021e6408edee4c002200ab3a07e3a87 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 2 Oct 2023 15:13:46 -0700 Subject: [PATCH] remove refresh from nav panel and add refresh button to channel panel --- .../gui/tabs/channels/ChannelTablePanel.java | 37 +++++++++++++++---- .../gui/tabs/navigation/NavigationPanel.java | 4 +- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/channels/ChannelTablePanel.java b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/channels/ChannelTablePanel.java index b37370e..45d8955 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/channels/ChannelTablePanel.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/channels/ChannelTablePanel.java @@ -20,6 +20,7 @@ public class ChannelTablePanel extends Panel { private Button btnAddChannel_; private Button btnRemoveChannel_; + private Button btnRefresh_; private ComboBox cmbChannelGroup_; private ComboBox cmbChannelMode_; @@ -41,9 +42,14 @@ private void createUserInterface() { table_ = new ChannelTable(model_); - Button.setDefaultSize(80, 24); + Button.setDefaultSize(72, 24); btnAddChannel_ = new Button("Add"); btnRemoveChannel_ = new Button("Remove"); + btnRefresh_ = new Button("Refresh"); + + btnAddChannel_.setToolTipText("Add a new channel to the table."); + 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 = getAvailableGroups(); cmbChannelGroup_ = new ComboBox(groupLabels, groupLabels[0]); @@ -54,14 +60,15 @@ private void createUserInterface() { add(lblChannelGroup_, "split 2"); add(cmbChannelGroup_, "wrap"); add(table_, "wrap"); - add(btnAddChannel_, "split 2"); - add(btnRemoveChannel_, "wrap"); + add(btnAddChannel_, "split 3"); + add(btnRemoveChannel_, ""); + add(btnRefresh_, "wrap"); add(lblChangeChannel_, "split 2"); add(cmbChannelMode_, ""); } private void createEventHandlers() { - final DefaultAcquisitionSettingsDISPIM.Builder asb_ = model_.acquisitions().settingsBuilder(); + final DefaultAcquisitionSettingsDISPIM.Builder asb = model_.acquisitions().settingsBuilder(); btnAddChannel_.registerListener(e -> { table_.getData().addEmptyChannel(); @@ -71,27 +78,41 @@ private void createEventHandlers() { // repaint(); System.out.println("add channel"); table_.getData().printChannelData(); - asb_.channels(table_.getData().getChannelArray()); + asb.channels(table_.getData().getChannelArray()); }); btnRemoveChannel_.registerListener(e -> { final int row = table_.getTable().getSelectedRow(); if (row != -1) { table_.getData().removeChannel(row); - asb_.channels(table_.getData().getChannelArray()); + asb.channels(table_.getData().getChannelArray()); table_.refreshData(); System.out.println("remove row index: " + row); } }); + btnRefresh_.registerListener(e -> { + final Object currentLabel = cmbChannelGroup_.getSelectedItem(); + final String[] groupLabels = getAvailableGroups(); + cmbChannelGroup_.removeAllItems(); + for (String label : groupLabels){ + cmbChannelGroup_.addItem(label); + System.out.println(label); + if (label.equals(currentLabel)) { + cmbChannelGroup_.setSelectedItem(currentLabel); + } + } + cmbChannelGroup_.updateUI(); + }); + cmbChannelMode_.registerListener(e -> { final int index = cmbChannelMode_.getSelectedIndex(); - asb_.channelMode(MultiChannelMode.getByIndex(index)); + asb.channelMode(MultiChannelMode.getByIndex(index)); //System.out.println("getChannelMode: " + model_.acquisitions().getAcquisitionSettings().getChannelMode()); }); cmbChannelGroup_.registerListener(e -> { - asb_.channelGroup(cmbChannelGroup_.getSelected()); + asb.channelGroup(cmbChannelGroup_.getSelected()); //System.out.println("getChannelGroup: " + model_.acquisitions().getAcquisitionSettings().getChannelGroup()); }); } diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/navigation/NavigationPanel.java b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/navigation/NavigationPanel.java index 0cb89bc..b53e18b 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/navigation/NavigationPanel.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/navigation/NavigationPanel.java @@ -176,7 +176,7 @@ public void createUserInterface() { if (devicesFound == 0) { add(new JLabel("No devices or device adapter properties are not set."), "wrap"); add(btnHaltDevices_, "wrap"); - add(btnRefreshPanel_, "wrap"); + //add(btnRefreshPanel_, "wrap"); add(cbxPollPositions_, ""); return; } @@ -224,7 +224,7 @@ public void createUserInterface() { add(miscPanel, "wrap"); add(btnHaltDevices_, "split 3"); - add(btnRefreshPanel_, ""); + //add(btnRefreshPanel_, ""); add(cbxPollPositions_, ""); }