Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove refresh from nav panel and add refresh button to channel panel #159

Merged
merged 1 commit into from
Oct 2, 2023
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 @@ -20,6 +20,7 @@ public class ChannelTablePanel extends Panel {

private Button btnAddChannel_;
private Button btnRemoveChannel_;
private Button btnRefresh_;

private ComboBox cmbChannelGroup_;
private ComboBox cmbChannelMode_;
Expand All @@ -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]);
Expand All @@ -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();
Expand All @@ -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());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -224,7 +224,7 @@ public void createUserInterface() {

add(miscPanel, "wrap");
add(btnHaltDevices_, "split 3");
add(btnRefreshPanel_, "");
//add(btnRefreshPanel_, "");
add(cbxPollPositions_, "");
}

Expand Down