Create DialogWrapper with TextFieldWithHistory()

Answered

Hello everyone, I'm new to plugin development and I need help determining the UI type of my plugin form.

I tried using DialogWrapper, but it doesn't seem to work for me. The logic of the plugin is as follows: 
I get a list of projects from gitlab and by selecting a project from the list, using the gitlab api I get a list of project branches and set this list in the "Branches" field. 
Actually the problem is that I don’t understand how I can get the current value of the “Repositories” field and then, depending on the choice, set the value of the “Branches” field. I create the panel as follows:

protected @Nullable JComponent createCenterPanel() {
	panel = new JPanel(new BorderLayout());JPanel panel = new JPanel(new BorderLayout());
	JLabel repository = new JLabel("Repository:");
	repository.setBorder(JBUI.Borders.emptyRight(10));
	TextFieldWithHistoryrepositoryField = new TextFieldWithHistory();
	JPanel repositoryPanel = new JPanel(new BorderLayout());
	repositoryField.setHistorySize(800);
	repositoryField.setHistory(projects);
	repositoryPanel.add(repository, BorderLayout.WEST);
	repositoryPanel.add(repositoryField);
	TextFieldWithHistory branchField = new TextFieldWithHistory();
 	JLabel branch = new JLabel("Branch:");
 	branch.setBorder(JBUI.Borders.emptyRight(10));
 	JPanel branchPanel = new JPanel(new BorderLayout());
 	branchField.setHistorySize(800);
 	branchPanel.add(branch, BorderLayout.WEST);
 	branchPanel.add(branchField);
	panel.add(repositoryPanel, BorderLayout.PAGE_START);
	panel.add(branchPanel, BorderLayout.CENTER);
	return panel;
}
0
2 comments

Hi,

Try adding listener for the repositoryField and fill the branches filed in the listener logic. Current repository value can be retrieved with TextFieldWithHistory.getText.

0

Thank you, I will try

0

Please sign in to leave a comment.