How to fill in ComboBox from API call?

Answered

I need to call an API, get a response, add items to ComboBox and update the view in the plugin.

I need to update the thread Ids as they load from an API. My custom Combobox for this is as shown below. I am not sure how to update the custom component from outside the class. Any help? 

public class MyComboBox extends AnAction implements CustomComponentAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {

}

@Override
public @NotNull JComponent createCustomComponent(@NotNull Presentation presentation, @NotNull String place) {

ComboBox<String> jComboBox = new ComboBox<>();
jComboBox.setMinLength(100);
jComboBox.addItem("Thread Id: " + UUID.randomUUID().toString());
jComboBox.addItem("Thread Id: " + UUID.randomUUID().toString());
jComboBox.setEnabled(true);

return jComboBox;

}

}

 

2 comments
Comment actions Permalink

I have declared the combobox in the action group in plugin.xml the following way:

<group id="Demo.DropDown" text="Select Thread Id here" description="Select Thread Id here">
<add-to-group group-id="MainToolBar" anchor="last"/>
<action class="actions.MyComboBox" description="Test Description" id="searchThread" text="Search Thread" icon="AllIcons.Actions.SearchWithHistory"/>
</group>
0
Comment actions Permalink

Please don't crosspost or at least link existing questions to avoid duplicate work

https://stackoverflow.com/questions/70728161/how-to-fill-in-combobox-from-an-api-call

0

Post is closed for comments.