use of com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor in project intellij-community by JetBrains.
the class GradleProgressEventConverter method convert.
@NotNull
public static ExternalSystemTaskNotificationEvent convert(ExternalSystemTaskId id, ProgressEvent event) {
final InternalOperationDescriptor internalDesc = event.getDescriptor() instanceof DefaultOperationDescriptor ? ((DefaultOperationDescriptor) event.getDescriptor()).getInternalOperationDescriptor() : null;
final String eventId = internalDesc == null ? event.getDescriptor().getDisplayName() : internalDesc.getId().toString();
final String parentEventId;
if (event.getDescriptor().getParent() == null) {
parentEventId = null;
} else {
parentEventId = internalDesc == null ? event.getDescriptor().getParent().getDisplayName() : internalDesc.getParentId().toString();
}
final String description = event.getDescriptor().getName();
if (event instanceof StartEvent) {
final OperationDescriptor descriptor = convert(event.getDescriptor(), event.getEventTime());
return new ExternalSystemTaskExecutionEvent(id, new ExternalSystemStartEventImpl<>(eventId, parentEventId, descriptor));
} else if (event instanceof FinishEvent) {
final OperationDescriptor descriptor = convert(event.getDescriptor(), event.getEventTime());
return new ExternalSystemTaskExecutionEvent(id, new ExternalSystemFinishEventImpl<>(eventId, parentEventId, descriptor, convert(((FinishEvent) event).getResult())));
} else if (event instanceof TaskProgressEvent) {
final OperationDescriptor descriptor = convert(event.getDescriptor(), event.getEventTime());
return new ExternalSystemTaskExecutionEvent(id, new BaseExternalSystemProgressEvent<>(eventId, parentEventId, descriptor));
} else {
return new ExternalSystemTaskNotificationEvent(id, description);
}
}
Aggregations