use of com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemNode in project intellij-community by JetBrains.
the class ExternalProjectPathField method createPanel.
@NotNull
public static MyPathAndProjectButtonPanel createPanel(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId) {
final EditorTextField textField = createTextField(project, externalSystemId);
final FixedSizeButton selectRegisteredProjectButton = new FixedSizeButton();
selectRegisteredProjectButton.setIcon(AllIcons.Actions.Module);
String tooltipText = ExternalSystemBundle.message("run.configuration.tooltip.choose.registered.project", externalSystemId.getReadableName());
selectRegisteredProjectButton.setToolTipText(tooltipText);
selectRegisteredProjectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final Ref<JBPopup> popupRef = new Ref<>();
final Tree tree = buildRegisteredProjectsTree(project, externalSystemId);
tree.setBorder(IdeBorderFactory.createEmptyBorder(8));
Runnable treeSelectionCallback = () -> {
TreePath path = tree.getSelectionPath();
if (path != null) {
Object lastPathComponent = path.getLastPathComponent();
if (lastPathComponent instanceof ExternalSystemNode) {
Object e1 = ((ExternalSystemNode) lastPathComponent).getDescriptor().getElement();
if (e1 instanceof ExternalProjectPojo) {
ExternalProjectPojo pojo = (ExternalProjectPojo) e1;
textField.setText(pojo.getPath());
Editor editor = textField.getEditor();
if (editor != null) {
collapseIfPossible(editor, externalSystemId, project);
}
}
}
}
popupRef.get().closeOk(null);
};
JBPopup popup = new PopupChooserBuilder(tree).setTitle(ExternalSystemBundle.message("run.configuration.title.choose.registered.project", externalSystemId.getReadableName())).setResizable(true).setItemChoosenCallback(treeSelectionCallback).setAutoselectOnMouseMove(true).setCloseOnEnter(false).createPopup();
popupRef.set(popup);
popup.showUnderneathOf(selectRegisteredProjectButton);
}
});
return new MyPathAndProjectButtonPanel(textField, selectRegisteredProjectButton);
}
Aggregations