本文整理匯總了Java中org.eclipse.core.runtime.SubProgressMonitor.setTaskName方法的典型用法代碼示例。如果您正苦於以下問題:Java SubProgressMonitor.setTaskName方法的具體用法?Java SubProgressMonitor.setTaskName怎麽用?Java SubProgressMonitor.setTaskName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.runtime.SubProgressMonitor
的用法示例。
在下文中一共展示了SubProgressMonitor.setTaskName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setTpMapping
import org.eclipse.core.runtime.SubProgressMonitor; //導入方法依賴的package包/類
/**
* Associates the specified mapping with the specified filename (optional
* operation). If the {@link Spec} previously contained a mapping for the
* filename, the old mapping is replaced by the specified map.
*
* @param mapping
* The {@link TLAtoPCalMapping} object for the given
* <tt>filename</tt>. <code>null</code>, will cause an
* {@link IllegalArgumentException}.
* @param filename
* key with which the specified value is to be associated.
* <code>null</code>, will cause an
* {@link IllegalArgumentException}.
* @param monitor
* A valid {@link IProgressMonitor}, <code>null</code>, will
* cause an {@link IllegalArgumentException}.
* @return the previous value associated with <tt>filename</tt>, or
* <tt>null</tt> if there was no mapping for <tt>filename</tt>.
* @throws NullPointerException
* if the specified key or value is null and this map does not
* permit null keys or values
* @throws IllegalArgumentException
* if some property of the specified key or value prevents it
* from being stored in this map
*/
public TLAtoPCalMapping setTpMapping(final TLAtoPCalMapping mapping,
final String filename, final IProgressMonitor monitor) {
// Safeguard against inproper use of this API
if (mapping == null || filename == null || monitor == null) {
throw new IllegalArgumentException();
}
lock.lock();
try {
final TLAtoPCalMapping oldMapping = spec2mappings.put(filename,
mapping);
// Check if old and new mapping are identical to avoid disk flush.
// This requires proper equals/hashcode in TLAtoPCalMapping and
// nested.
if (!mapping.equals(oldMapping)) {
// Use a submonitor to show progress as well as failure
final SubProgressMonitor subProgressMonitor = new SubProgressMonitor(
monitor, 1);
subProgressMonitor
.setTaskName("Writing TLA+ to PCal mapping for "
+ filename);
// Eagerly flush mapping to its persistent disk storage
// (overwriting
// any previous mapping stored on disk). This is relatively
// cheap
// compared to how often a mapping is re-generated, but has the
// advantage that the mapping doesn't get lost if the Toolbox
// decides to
// not shut down gracefully.
try {
Assert.isTrue(ResourceHelper.writeTLAtoPCalMapping(project,
filename, mapping, subProgressMonitor));
} finally {
subProgressMonitor.done();
}
}
return oldMapping;
} finally {
lock.unlock();
}
}