/** * Finish the currently executing progress operation. * * @param monitor * @throws SiteWhereException */ public static void finishProgressOperation(ILifecycleProgressMonitor monitor) throws SiteWhereException { ILifecycleProgressContext context = monitor.getContextStack().peek(); if (context == null) { throw new SiteWhereException("Unable to finish operation. No context available."); } // Report progress based on new operation. String task = monitor.getContextStack().getLast().getCurrentOperationMessage(); String current = monitor.getContextStack().getFirst().getCurrentOperationMessage(); Deque<ILifecycleProgressContext> queue = new ArrayDeque<>(monitor.getContextStack()); double progress = computeSubprogressFor(queue, 100.0); monitor.reportProgress(new ProgressMessage(task, progress, current)); }
/** * Finish the currently executing progress operation. * * @param monitor * @throws SiteWhereException */ public static void finishProgressOperation(ILifecycleProgressMonitor monitor) throws SiteWhereException { ILifecycleProgressContext context = monitor.getContextStack().peek(); if (context == null) { throw new SiteWhereException("Unable to finish operation. No context available."); } // Report progress based on new operation. String task = monitor.getContextStack().getLast().getCurrentOperationMessage(); String current = monitor.getContextStack().getFirst().getCurrentOperationMessage(); Deque<ILifecycleProgressContext> queue = new ArrayDeque<>(monitor.getContextStack()); double progress = computeSubprogressFor(queue, 100.0); monitor.reportProgress(new ProgressMessage(task, progress, current)); }
/** * Common logic for starting an operation on an * {@link ILifecycleProgressMonitor}. * * @param monitor * @param operation * @throws SiteWhereException */ public static void startProgressOperation(ILifecycleProgressMonitor monitor, String operation) throws SiteWhereException { ILifecycleProgressContext context = monitor.getContextStack().peek(); if (context == null) { throw new SiteWhereException("Unable to start operation. No context available."); } int newIndex = context.getCurrentOperationIndex() + 1; if (newIndex > context.getOperationCount()) { throw new SiteWhereException( "Unable to start operation. Index will exceed expected operation count. Operation was: " + operation); } context.setCurrentOperationIndex(newIndex); context.setCurrentOperationMessage(operation); }
/** * Common logic for starting an operation on an * {@link ILifecycleProgressMonitor}. * * @param monitor * @param operation * @throws SiteWhereException */ public static void startProgressOperation(ILifecycleProgressMonitor monitor, String operation) throws SiteWhereException { ILifecycleProgressContext context = monitor.getContextStack().peek(); if (context == null) { throw new SiteWhereException("Unable to start operation. No context available."); } int newIndex = context.getCurrentOperationIndex() + 1; if (newIndex > context.getOperationCount()) { throw new SiteWhereException( "Unable to start operation. Index will exceed expected operation count. Operation was: " + operation); } context.setCurrentOperationIndex(newIndex); context.setCurrentOperationMessage(operation); }