Search in sources :

Example 6 with ParentableNode

use of com.redhat.devtools.intellij.tektoncd.tree.ParentableNode 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);
    }
}
Also used : ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode) TektonTreeStructure(com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure) Tree(com.intellij.ui.treeStructure.Tree)

Example 7 with ParentableNode

use of com.redhat.devtools.intellij.tektoncd.tree.ParentableNode in project intellij-tekton by redhat-developer.

the class FindTaskRefAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    TelemetryMessageBuilder.ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_MISC + "find task references").property(PROP_RESOURCE_KIND, KIND_TASK);
    ParentableNode element = getElement(selected);
    ExecHelper.submit(() -> {
        try {
            List<RefUsage> usages = tkncli.findTaskUsages(KIND_TASK, element.getName());
            UIHelper.executeInUI(() -> FindTaskRefPanelBuilder.instance().build(anActionEvent.getProject(), KIND_TASK, element.getName(), usages));
            telemetry.send();
        } catch (IOException e) {
            telemetry.error(anonymizeResource(null, element.getNamespace(), e.getMessage())).send();
            logger.warn(e.getLocalizedMessage(), e);
        }
    });
}
Also used : ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode) RefUsage(com.redhat.devtools.intellij.tektoncd.ui.toolwindow.findusage.RefUsage) TelemetryMessageBuilder(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder) IOException(java.io.IOException)

Example 8 with ParentableNode

use of com.redhat.devtools.intellij.tektoncd.tree.ParentableNode in project intellij-tekton by redhat-developer.

the class CancelAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_START_STOP + "cancel");
    ExecHelper.submit(() -> {
        ParentableNode element = getElement(selected);
        String namespace = element.getNamespace();
        try {
            if (element instanceof PipelineRunNode) {
                tkncli.cancelPipelineRun(namespace, element.getName());
                telemetry.property(TelemetryService.PROP_RESOURCE_KIND, Constants.KIND_PIPELINERUN).send();
            } else if (element instanceof TaskRunNode) {
                tkncli.cancelTaskRun(namespace, element.getName());
                telemetry.property(TelemetryService.PROP_RESOURCE_KIND, Constants.KIND_TASKRUN).send();
            }
        } catch (IOException e) {
            telemetry.error(anonymizeResource(element.getName(), namespace, e.getMessage())).send();
            Notification notification = new Notification(NOTIFICATION_ID, "Error", element.getName() + " in namespace " + namespace + " failed to cancel\n" + e.getLocalizedMessage(), NotificationType.ERROR);
            Notifications.Bus.notify(notification);
            logger.warn("Error: " + e.getLocalizedMessage(), e);
        }
    });
}
Also used : ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode) ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) TaskRunNode(com.redhat.devtools.intellij.tektoncd.tree.TaskRunNode) IOException(java.io.IOException) Notification(com.intellij.notification.Notification) PipelineRunNode(com.redhat.devtools.intellij.tektoncd.tree.PipelineRunNode)

Example 9 with ParentableNode

use of com.redhat.devtools.intellij.tektoncd.tree.ParentableNode in project intellij-tekton by redhat-developer.

the class DeleteAction method getDeleteText.

private String getDeleteText(Tkn tkn, ParentableNode[] elements) {
    StringBuilder sb = new StringBuilder("Are you sure you want to delete ");
    if (elements.length == 1) {
        String name = elements[0].getName();
        String kind = elements[0].getClass().getSimpleName().toLowerCase().replace("node", "");
        int usages = getUsages(tkn, kind, name);
        if (usages > 0) {
            sb.insert(0, "This " + kind + " is being used by other resources. ");
        }
        sb.append(kind + " " + name + " ?");
    } else {
        sb.append("the following items?\n");
        for (ParentableNode element : elements) {
            String kind = elements[0].getClass().getSimpleName().toLowerCase().replace("node", "");
            sb.append(element.getName() + getUsagesAsText(tkn, kind, element.getName()) + "\n");
        }
    }
    return sb.toString();
}
Also used : ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode)

Example 10 with ParentableNode

use of com.redhat.devtools.intellij.tektoncd.tree.ParentableNode in project intellij-tekton by redhat-developer.

the class ShowDiagnosticDataAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    ActionMessage telemetry = instance().action(NAME_PREFIX_DIAG + "show diagnostic data");
    ExecHelper.submit(() -> {
        ParentableNode element = getElement(selected);
        String namespace = element.getNamespace();
        boolean hasDataToShow = false;
        try {
            if (element instanceof PipelineRunNode) {
                telemetry.property(PROP_RESOURCE_KIND, Constants.KIND_PIPELINERUN);
                hasDataToShow = tkncli.getDiagnosticData(namespace, "tekton.dev/pipelineRun", element.getName());
            } else if (element instanceof TaskRunNode) {
                telemetry.property(PROP_RESOURCE_KIND, Constants.KIND_TASKRUN);
                hasDataToShow = tkncli.getDiagnosticData(namespace, "tekton.dev/taskRun", element.getName());
            }
            if (!hasDataToShow) {
                String message = "No data available for " + element.getName() + " in namespace " + namespace + ".";
                telemetry.result(anonymizeResource(element.getName(), namespace, message)).send();
                UIHelper.executeInUI(() -> Messages.showWarningDialog("No data available for " + element.getName() + " in namespace " + namespace + ".", "Diagnostic Data"));
            } else {
                telemetry.success().send();
            }
        } catch (IOException e) {
            telemetry.error(anonymizeResource(element.getName(), namespace, e.getMessage())).send();
            UIHelper.executeInUI(() -> Messages.showErrorDialog("Failed to retrieve data for " + element.getName() + " in namespace " + namespace + ". An error occurred while retrieving them.\n" + e.getLocalizedMessage(), "Error"));
            logger.warn("Error: " + e.getLocalizedMessage(), e);
            return;
        }
    });
}
Also used : ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode) ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) TaskRunNode(com.redhat.devtools.intellij.tektoncd.tree.TaskRunNode) IOException(java.io.IOException) PipelineRunNode(com.redhat.devtools.intellij.tektoncd.tree.PipelineRunNode)

Aggregations

ParentableNode (com.redhat.devtools.intellij.tektoncd.tree.ParentableNode)13 IOException (java.io.IOException)8 ActionMessage (com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage)6 Notification (com.intellij.notification.Notification)4 PipelineRunNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineRunNode)4 TaskRunNode (com.redhat.devtools.intellij.tektoncd.tree.TaskRunNode)4 TektonTreeStructure (com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure)3 RefUsage (com.redhat.devtools.intellij.tektoncd.ui.toolwindow.findusage.RefUsage)3 Project (com.intellij.openapi.project.Project)2 PipelineNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Messages (com.intellij.openapi.ui.Messages)1 Tree (com.intellij.ui.treeStructure.Tree)1 ExecHelper (com.redhat.devtools.intellij.common.utils.ExecHelper)1 UIHelper (com.redhat.devtools.intellij.common.utils.UIHelper)1 Constants (com.redhat.devtools.intellij.tektoncd.Constants)1 KIND_CLUSTERTASK (com.redhat.devtools.intellij.tektoncd.Constants.KIND_CLUSTERTASK)1 KIND_TASK (com.redhat.devtools.intellij.tektoncd.Constants.KIND_TASK)1