use of com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure in project intellij-tekton by redhat-developer.
the class WindowToolFactory method createToolWindowContent.
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
try {
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
TektonTreeStructure structure = new TektonTreeStructure(project);
StructureTreeModel<TektonTreeStructure> model = buildModel(structure, project);
new MutableTektonModelSynchronizer<>(model, structure, structure);
Tree tree = new Tree(new AsyncTreeModel(model, project));
tree.putClientProperty(Constants.STRUCTURE_PROPERTY, structure);
tree.setCellRenderer(new NodeRenderer());
ActionManager actionManager = ActionManager.getInstance();
ActionGroup group = (ActionGroup) actionManager.getAction("com.redhat.devtools.intellij.tektoncd.tree");
PopupHandler.installPopupHandler(tree, group, ActionPlaces.POPUP, actionManager, new TektonTreePopupMenuListener());
new TektonTreeDoubleClickListener(tree);
TknCliFactory.getInstance().getTkn(project).whenComplete((tkn, err) -> {
HubModel hubModel = new HubModel(project, tkn, null);
JPanel hubItemsListPanel = new HubItemPanelsBoard(hubModel, getDoSelectAction(project, hubModel)).withRecommended().withInstalled().build(Optional.empty());
OnePixelSplitter tabPanel = createTabPanel(new JBScrollPane(tree), hubItemsListPanel);
toolWindow.getContentManager().addContent(contentFactory.createContent(tabPanel, "", false));
executeOnProjectClosing(project, () -> {
structure.dispose();
hubModel.dispose();
});
});
} catch (IllegalAccessException | InvocationTargetException | InstantiationException | NoSuchMethodException e) {
throw new RuntimeException((e));
}
}
use of com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure in project intellij-tekton by redhat-developer.
the class TreeHelper method getTkn.
public static Tkn getTkn(Project project) {
try {
TektonTreeStructure treeStructure = (TektonTreeStructure) getTree(project).getClientProperty(Constants.STRUCTURE_PROPERTY);
TektonRootNode root = (TektonRootNode) treeStructure.getRootElement();
return root.getTkn();
} catch (Exception ex) {
return null;
}
}
use of com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure in project intellij-tekton by redhat-developer.
the class DeleteAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath[] path, Object[] selected, Tkn tkncli) {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "delete resource");
ParentableNode[] elements = Arrays.stream(selected).map(item -> getElement(item)).toArray(ParentableNode[]::new);
ExecHelper.submit(() -> {
String deleteText = getDeleteText(tkncli, elements);
int resultDialog = UIHelper.executeInUI(() -> {
DeleteDialog delDialog = new DeleteDialog(null, getTitle(elements), deleteText, getDeleteChkText(elements));
delDialog.show();
if (delDialog.isOK()) {
return delDialog.hasToDeleteRelatedResources() ? OK_DELETE_RESOURCES_CODE : OK_DELETE_CODE;
}
return CANCEL_CODE;
});
if (resultDialog != CANCEL_CODE) {
String namespace = elements[0].getNamespace();
boolean deleteRelatedResources = resultDialog == OK_DELETE_RESOURCES_CODE;
Map<Class, List<ParentableNode>> resourcesByClass = TreeHelper.getResourcesByClass(elements);
for (Class type : resourcesByClass.keySet()) {
try {
deleteResources(type, resourcesByClass, namespace, deleteRelatedResources, tkncli);
((TektonTreeStructure) getTree(anActionEvent).getClientProperty(Constants.STRUCTURE_PROPERTY)).fireModified(resourcesByClass.get(type).get(0).getParent());
telemetry.property(TelemetryService.PROP_RESOURCE_KIND, type.getSimpleName()).property(TelemetryService.PROP_RESOURCE_RELATED, String.valueOf(deleteRelatedResources)).success().send();
} catch (IOException e) {
telemetry.error(anonymizeResource(null, namespace, e.getMessage())).send();
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Error"));
}
}
}
});
}
use of com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure in project intellij-tekton by redhat-developer.
the class RefreshAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected) {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_MISC + "refresh");
selected = StructureTreeAction.getElement(selected);
TektonTreeStructure structure = (TektonTreeStructure) getTree(anActionEvent).getClientProperty(Constants.STRUCTURE_PROPERTY);
structure.fireModified(selected);
telemetry.property(PROP_RESOURCE_KIND, selected.getClass().getSimpleName()).send();
}
use of com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure in project intellij-tekton by redhat-developer.
the class RefreshQueue method update.
public void update() {
while (!queue.isEmpty()) {
ParentableNode element = queue.poll();
Tree tree = TreeHelper.getTree(element.getRoot().getProject());
TektonTreeStructure treeStructure = (TektonTreeStructure) tree.getClientProperty(Constants.STRUCTURE_PROPERTY);
treeStructure.fireModified(element);
}
}
Aggregations