I have an Oscillator tab in the UI with various Oscillators that I can select from the drop-down menu and want to change the UI/ tabs based on the respective Oscillator. The UI can be like this:
The initialize method is provided below:
This is the enum that holds the Oscillators:
I would like to add an event listener to the Oscillator category change and if the Oscillator changed, the UI (say, another tab) needs to change based on that.
How do I add an event listener, at least to log/ print that the category is changing by the customer?
The initialize method is provided below:
Code:
@Override
public void initialize(Defaults defaults) {
var sd = createSD();
var oscillatorsTab = sd.addTab("Oscillators");
var osInputs = oscillatorsTab.addGroup("Oscillators");
Object[] oscillatorTypes = new Object[Oscillators.values().length];
int index = 0;
for (Oscillators os : Oscillators.values()) {
oscillatorTypes[index++] = os.getLabel();
}
InputDescriptor category = new InputDescriptor(Inputs.INPUT, "Category", oscillatorTypes, Oscillators.RATE_OF_CHAANGE);
osInputs.addRow(category);
var tab = sd.addTab(get("TAB_GENERAL"));
var inputs = tab.addGroup(get("LBL_INPUTS"));
inputs.addRow(new InputDescriptor(Inputs.INPUT, get("LBL_INPUT"), Enums.BarInput.values(), Enums.BarInput.CLOSE));
inputs.addRow(new IntegerDescriptor(Inputs.PERIOD, get("LBL_PERIOD"), 14, 1, 9999, 1));
var lines = tab.addGroup(get("LBL_COLORS"));
lines.addRow(new PathDescriptor(Inputs.PATH, get("LBL_LINE"), defaults.getLineColor(), 1.0f, null));
lines.addRow(new IndicatorDescriptor(Inputs.IND, get("LBL_INDICATOR"), null, null, false, true, true));
// Quick Settings (Tool Bar and Popup Editor)
sd.addQuickSettings(Inputs.INPUT);
sd.addQuickSettings(new SliderDescriptor(Inputs.PERIOD, get("LBL_PERIOD"), 14, 1, 9999, true, Enums.Icon.SINE_WAVE::get));
sd.addQuickSettings(Inputs.PATH);
var desc = createRD();
desc.setLabelSettings(Inputs.INPUT, Inputs.PERIOD);
desc.exportValue(new ValueDescriptor(Momentum.Values.M, get("LBL_MOMENTUM"), new String[]{Inputs.INPUT, Inputs.PERIOD}));
desc.declarePath(Momentum.Values.M, Inputs.PATH);
desc.declareIndicator(Momentum.Values.M, Inputs.IND);
desc.setRangeKeys(Momentum.Values.M);
}
This is the enum that holds the Oscillators:
Code:
enum Oscillators {
MOMENTUM(MyUtil.strings.get("Momentum", new Object[0]), "Momentum"),
RATE_OF_CHAANGE(MyUtil.strings.get("Rate Of Change", new Object[0]), "Rate Of Change"),
RSI(MyUtil.strings.get("Relative Strength Index", new Object[0]), "Relative Strength Index");
}
I would like to add an event listener to the Oscillator category change and if the Oscillator changed, the UI (say, another tab) needs to change based on that.
How do I add an event listener, at least to log/ print that the category is changing by the customer?
Last edited: