Skip to content

Commit

Permalink
-Remove subs from viewer when user removes them in UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-gomez-windhover committed Dec 15, 2023
1 parent f037d72 commit aca9787
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,16 @@ public void onChanged(ListChangeListener.Change<? extends ViewablePV> c) {
}
} else {
viewableSet.remove(item.paramProperty().get());
try {
pv = PVPool.getPV(item.paramProperty().get());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (pv != null && !newPV) {
// pvSubscription(pv);
oldSubs.get(item.paramProperty().get()).dispose();
paramsView.removeParam(item.paramProperty().get());
}
}
paramsView.getParameters().clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
import javafx.scene.layout.VBox;
import org.phoebus.framework.persistence.Memento;

/**
* Panel for exporting data into files
*
* @author lgomez
*/
/** @author lgomez */
@SuppressWarnings("nls")
public class ParameterViewerView extends VBox {
private final ListView<Copyable> ParamsTable = new ListView<Copyable>();
Expand Down Expand Up @@ -54,7 +50,6 @@ public void updateParams(Set<String> PVs) {
// This impl could really use some improvements
boolean exists = false;
for (var pv : PVs) {
System.out.println("updateParams***:" + pv);
for (var p : params) {
if (p.getText().contains(pv)) {
exists = true;
Expand All @@ -63,14 +58,27 @@ public void updateParams(Set<String> PVs) {
}

if (!exists) {
System.out.println("Add To Params***");
params.add(new Copyable(pv));
}

exists = false;
}
}

public void removeParam(String pvName) {
// TODO: I really need to use a HashMap, instead of using these horrid hacks.
int indexOfParam = -1;
for (var p : params) {
if (p.getText().contains(pvName)) {
indexOfParam = params.indexOf(p);
break;
}
}
if (indexOfParam != -1) {
params.remove(indexOfParam);
}
}

public void updateParamValue(String value, String PV) {
for (var p : params) {
if (p.getText().contains(PV)) {
Expand Down

0 comments on commit aca9787

Please sign in to comment.