本文整理汇总了Java中org.netbeans.api.progress.ProgressHandle.switchToDeterminate方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressHandle.switchToDeterminate方法的具体用法?Java ProgressHandle.switchToDeterminate怎么用?Java ProgressHandle.switchToDeterminate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.progress.ProgressHandle
的用法示例。
在下文中一共展示了ProgressHandle.switchToDeterminate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finnishProgress
import org.netbeans.api.progress.ProgressHandle; //导入方法依赖的package包/类
@Override
protected void finnishProgress() {
// TODO add failed and restart texts
if (isCanceled()) {
getLogger().logCommandLine("==[IDE]== " + DateFormat.getDateTimeInstance().format(new Date()) + " " + runningName + " " + NbBundle.getMessage(ContextAction.class, "MSG_Progress_Canceled")); // NOI18N
} else {
final ProgressHandle progress = getProgressHandle();
progress.switchToDeterminate(100);
progress.progress(NbBundle.getMessage(ContextAction.class, "MSG_Progress_Done"), 100); // NOI18N
if (System.currentTimeMillis() > progressStamp) {
Subversion.getInstance().getParallelRequestProcessor().post(new Runnable() {
@Override
public void run() {
progress.finish();
}
}, 15 * 1000);
} else {
progress.finish();
}
getLogger().logCommandLine("==[IDE]== " + DateFormat.getDateTimeInstance().format(new Date()) + " " + runningName + " " + NbBundle.getMessage(ContextAction.class, "MSG_Progress_Finished")); // NOI18N
}
}
示例2: run
import org.netbeans.api.progress.ProgressHandle; //导入方法依赖的package包/类
@Override
public Void run(ProgressHandle handle) {
handle.switchToDeterminate(fixes.size());
int clock = 0;
for (FixDescription f : fixes) {
if (cancel.get()) break;
try {
f.implement();
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
} finally {
handle.progress(++clock);
}
}
handle.finish();
return null;
}
示例3: run
import org.netbeans.api.progress.ProgressHandle; //导入方法依赖的package包/类
@Override
public String run(ProgressHandle handle) {
handle.switchToDeterminate(5);
for (int i= 0; i < 5; i++) {
handle.progress("Job " + i, i);
}
return "Done";
}
示例4: build
import org.netbeans.api.progress.ProgressHandle; //导入方法依赖的package包/类
@org.netbeans.api.annotations.common.SuppressWarnings("OS_OPEN_STREAM")
@Messages({
"# {0} - ZIP file", "MSG_building=Building {0}",
"# {0} - ZIP entry name", "MSG_packed=Packed: {0}"
})
private static boolean build(File root, File zip) throws IOException {
final AtomicBoolean canceled = new AtomicBoolean();
ProgressHandle handle = ProgressHandleFactory.createHandle(MSG_building(zip.getName()), new Cancellable() {
@Override public boolean cancel() {
return canceled.compareAndSet(false, true);
}
});
handle.start();
try {
List<String> files = new ArrayList<String>();
scanForFiles(root, files, "", handle, canceled, true);
if (canceled.get()) {
return false;
}
handle.switchToDeterminate(files.size());
OutputStream os = new FileOutputStream(zip);
try {
ZipOutputStream zos = new ZipOutputStream(os);
Set<String> written = new HashSet<String>();
String prefix = root.getName() + '/';
for (int i = 0; i < files.size(); i++) {
if (canceled.get()) {
return false;
}
String name = files.get(i);
writeEntry(prefix + name, written, zos, new File(root, name));
handle.progress(MSG_packed(name), i);
}
zos.finish();
zos.close();
} finally {
os.close();
}
} finally {
handle.finish();
}
return true;
}