本文整理匯總了Java中org.eclipse.core.runtime.SubProgressMonitor.subTask方法的典型用法代碼示例。如果您正苦於以下問題:Java SubProgressMonitor.subTask方法的具體用法?Java SubProgressMonitor.subTask怎麽用?Java SubProgressMonitor.subTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.runtime.SubProgressMonitor
的用法示例。
在下文中一共展示了SubProgressMonitor.subTask方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: expandChildChangesets
import org.eclipse.core.runtime.SubProgressMonitor; //導入方法依賴的package包/類
/**
* Expands the given list of {@link Changeset}s into a potentially larger
* list by following any branch/merge children that need followed (applies
* to TFS 2010 and later changesets, but harmless to follow changesets from
* previous servers).
*
* Consumes one unit of work from the given {@link IProgressMonitor}.
*
* @param progressMonitor
* a progress monitor used for cancellation and status repotring; 1
* unit of work will be used by this method (must not be
* <code>null</code>)
* @param changesets
* the changesets to expand children of (must not be
* <code>null</code>)
* @return the expanded changesets, never <code>null</code>
* @throws CoreException
* if cancelled
*/
private Changeset[] expandChildChangesets(final IProgressMonitor progressMonitor, final Changeset[] changesets)
throws CoreException {
Check.notNull(progressMonitor, "progressMonitor"); //$NON-NLS-1$
Check.notNull(changesets, "changesets"); //$NON-NLS-1$
/*
* Use a sub monitor to give the user more feedback.
*/
final SubProgressMonitor expandChildrenMonitor = new SubProgressMonitor(progressMonitor, 1);
try {
expandChildrenMonitor.beginTask(
Messages.getString("AnnotateCommand.ProgressFollowBranch"), //$NON-NLS-1$
changesets.length);
final List expandedChangesetList = new ArrayList();
for (int i = 0; i < changesets.length; i++) {
checkForCancellation(expandChildrenMonitor);
expandChildrenMonitor.subTask(
Messages.getString("AnnotateCommand.ProgressGetMergeHistory") + changesets[i].getChangesetID()); //$NON-NLS-1$
// Always add the original.
expandedChangesetList.add(changesets[i]);
// check if we have children
if (HistoryManager.mayHaveChildren(repository, changesets[i])) {
final Changeset[] children = HistoryManager.findChangesetChildren(repository, changesets[i]);
if (children != null && children.length > 0) {
expandedChangesetList.addAll(Arrays.asList(children));
}
}
expandChildrenMonitor.worked(1);
}
return (Changeset[]) expandedChangesetList.toArray(new Changeset[expandedChangesetList.size()]);
} finally {
expandChildrenMonitor.worked(1);
}
}
示例2: downloadTempFiles
import org.eclipse.core.runtime.SubProgressMonitor; //導入方法依賴的package包/類
/**
* Downloads this command's current resource in each of the given changesets
* to temporary files on disk.
*
* Consumes one unit of work from the given {@link IProgressMonitor}.
*
* @param progressMonitor
* a progress monitor used for cancellation and status repotring and
* passed to {@link GetVersionedItemToTempLocationCommand}; 1 unit of
* work will be used by this method (must not be <code>null</code>)
* @param multiStatus
* a {@link MultiStatus} into which the status of the download
* commands will be merged (must not be <code>null</code>)
* @param changesets
* the changesets to download items for (must not be
* <code>null</code>)
* @return the {@link Map} of {@link Changeset} to {@link File} or
* <code>null</code> if the user cancelled
* @throws Exception
* if {@link GetVersionedItemToTempLocationCommand} throw an
* exception
*/
private Map downloadTempFiles(
final IProgressMonitor progressMonitor,
final MultiStatus multiStatus,
final Changeset[] changesets) throws Exception {
final Map changesetToFilePathMap = new LinkedHashMap();
/*
* Use a sub monitor to give the user more feedback.
*/
final SubProgressMonitor downloadMonitor = new SubProgressMonitor(progressMonitor, 1);
try {
downloadMonitor.beginTask(
Messages.getString("AnnotateCommand.ProgressRetrievingHistory"), //$NON-NLS-1$
changesets.length);
for (int i = 0; i < changesets.length; i++) {
checkForCancellation(downloadMonitor);
final Changeset changeset = changesets[i];
final String messageFormat = Messages.getString("AnnotateCommand.ProgressRetrievingHistoryFormat"); //$NON-NLS-1$
final String message =
MessageFormat.format(messageFormat, Integer.toString(changeset.getChangesetID()));
downloadMonitor.subTask(message);
final Item item = changeset.getChanges()[0].getItem();
final GetVersionedItemToTempLocationCommand cmd = new GetVersionedItemToTempLocationCommand(
repository,
item.getServerItem(),
new ChangesetVersionSpec(changeset.getChangesetID()));
final IStatus status = cmd.run(new NullProgressMonitor());
multiStatus.merge(status);
if (status.isOK()) {
final String tempFilePath = cmd.getTempLocation();
if (tempFilePath != null) {
changesetToFilePathMap.put(changeset, tempFilePath);
}
findChangeBlocks(changesetToFilePathMap);
}
downloadMonitor.worked(1);
}
} finally {
downloadMonitor.done();
}
return changesetToFilePathMap;
}