use of com.redhat.devtools.intellij.tektoncd.tree.ConditionsNode in project intellij-tekton by redhat-developer.
the class CreateConditionAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "create condition").property(PROP_RESOURCE_KIND, KIND_CONDITION);
ConditionsNode item = getElement(selected);
String namespace = item.getParent().getName();
String content = getSnippet("Tekton: Condition");
if (Strings.isNullOrEmpty(content)) {
telemetry.error("snippet content empty.").send();
} else {
String name = namespace + "-newcondition.yaml";
try {
VirtualFileHelper.createAndOpenVirtualFile(anActionEvent.getProject(), namespace, name, content, KIND_CONDITIONS, item);
telemetry.send();
} catch (IOException e) {
telemetry.error(anonymizeResource(name, namespace, e.getMessage())).send();
logger.warn("Could not create condition: " + e.getLocalizedMessage(), e);
}
}
}
use of com.redhat.devtools.intellij.tektoncd.tree.ConditionsNode in project intellij-tekton by redhat-developer.
the class WatchNodes method setWatchByNode.
public void setWatchByNode(ParentableNode<?> element) {
String namespace = element.getNamespace();
String watchId = getWatchId(element);
Watch watch = null;
WatchNodes wn = null;
// (e.g a taskRuns watcher, when a change happens, could update multiple nodes such as a single Task node and the TaskRuns node)
if (this.watches.containsKey(watchId)) {
wn = this.watches.get(watchId);
if (wn.getNodes().stream().noneMatch(item -> item.getName().equalsIgnoreCase(element.getName()) && ((ParentableNode) item.getParent()).getName().equalsIgnoreCase(((ParentableNode) element.getParent()).getName()))) {
wn.getNodes().add(element);
}
return;
}
Watcher watcher = getWatcher(watchId, element.getRoot().getProject());
try {
if (element instanceof PipelinesNode) {
watch = tkn.watchPipelines(namespace, watcher);
} else if (element instanceof PipelineNode) {
// we are expanding a single pipeline node and we want it to refresh if its children (pipelineruns) change
watch = tkn.watchPipelineRuns(namespace, watcher);
} else if (element instanceof PipelineRunsNode) {
watch = tkn.watchPipelineRuns(namespace, watcher);
} else if (element instanceof PipelineRunNode) {
// we are expanding a single pipelinerun node and we want it to refresh if its children (taskruns) change
watch = tkn.watchTaskRuns(namespace, watcher);
} else if (element instanceof ResourcesNode) {
watch = tkn.watchPipelineResources(namespace, watcher);
} else if (element instanceof TasksNode) {
watch = tkn.watchTasks(namespace, watcher);
} else if (element instanceof TaskNode) {
// we are expanding a single task node and we want it to refresh if its children (taskruns) change
watch = tkn.watchTaskRuns(namespace, watcher);
} else if (element instanceof TaskRunsNode) {
watch = tkn.watchTaskRuns(namespace, watcher);
} else if (element instanceof ClusterTasksNode) {
watch = tkn.watchClusterTasks(watcher);
} else if (element instanceof ConditionsNode) {
watch = tkn.watchConditions(namespace, watcher);
} else if (element instanceof TriggerTemplatesNode) {
watch = tkn.watchTriggerTemplates(namespace, watcher);
} else if (element instanceof TriggerBindingsNode) {
watch = tkn.watchTriggerBindings(namespace, watcher);
} else if (element instanceof ClusterTriggerBindingsNode) {
watch = tkn.watchClusterTriggerBindings(watcher);
} else if (element instanceof EventListenersNode) {
watch = tkn.watchEventListeners(namespace, watcher);
}
wn = new WatchNodes(watch, element);
} catch (IOException e) {
logger.warn("Error: " + e.getLocalizedMessage(), e);
}
if (wn != null) {
watches.put(watchId, wn);
}
}
Aggregations