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);
}
}
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);
}
});
}
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);
}
});
}
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();
}
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;
}
});
}
Aggregations