本文整理汇总了Java中javax.swing.ProgressMonitor.close方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressMonitor.close方法的具体用法?Java ProgressMonitor.close怎么用?Java ProgressMonitor.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ProgressMonitor
的用法示例。
在下文中一共展示了ProgressMonitor.close方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBackup
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public void createBackup(Component c, String name, CCDate date, boolean persistent, String jccversion, String dbversion) {
if (CCProperties.getInstance().ARG_READONLY) {
CCLog.addInformation(LocaleBundle.getString("LogMessage.OperationFailedDueToReadOnly")); //$NON-NLS-1$
return;
}
CCLog.addInformation(LocaleBundle.getString("LogMessage.BackupStarted")); //$NON-NLS-1$
ProgressMonitor monitor = DialogHelper.getLocalPersistentProgressMonitor(c, "MainFrame.backupRunning"); //$NON-NLS-1$
try {
createBackupInternal(name, date, persistent, jccversion, dbversion, new ProgressCallbackProgressMonitorHelper(monitor), false);
} catch (IOException e) {
CCLog.addError(e);
monitor.setProgress(monitor.getMaximum());
monitor.close();
return;
}
monitor.setProgress(monitor.getMaximum());
monitor.close();
CCLog.addInformation(LocaleBundle.getString("LogMessage.BackupCreated")); //$NON-NLS-1$
CCProperties.getInstance().PROP_BACKUP_LASTBACKUP.setValue(CCDate.getCurrentDate());
}
示例2: export
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public boolean export(OutputStream out)
throws IOException, NoninvertibleTransformException {
this.out = out;
List lines = ornament.getLines();
int nLines = lines.size(), maxProgress = nLines + 2;
ProgressMonitor pm = new ProgressMonitor(ornament, I18n._("exporting"),
null, 0, maxProgress);
init();
prepareStream();
pm.setProgress(1);
head();
BufferedImage bg = ornament.getBackgroundTile();
if (bg != null) background(bg);
for (int i = 0; i != nLines && !pm.isCanceled(); ++i) {
pm.setProgress(2+i);
export((LinPath)lines.get(i));
}
pm.setProgress(2+nLines);
postBody();
tail();
if (out != null) out.close();
pm.close();
return true;
}
示例3: preview
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
private SolverState preview(boolean finall) {
PaintThing.lookup.put( HalfMesh2.class, new SuperMeshPainter() );
PaintThing.debug.clear();
plot.toPaint.clear();
SkelFootprint sf = updateVars();
if (finall)
sf.exitA = false;
ProgressMonitor pm = new ProgressMonitor( null, "working","...", 0, 100 );
SolverState SS;
try {
SS = sf.buildFootprint(
profileGen.footprint, pm, features, profileGen.blockGen );
}
finally {
pm.close();
}
if (SS != null) {
System.out.println("done");
plot.toPaint.add( profileGen.blockGen.nameCoords() );
plot.toPaint.add( SS.mesh );
plot.toPaint.add( SS.miniPainter() );
}
else
PaintThing.debug(Color.red, 1, "Bad state");
plot.repaint();
return SS;
}
示例4: runAnnotation
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
private boolean runAnnotation() {
theThread.start();
// launch progress dialog
progressDialog = new ProgressMonitor(theApplication, "Matching peaks with fragments", null, 0, theThread.getTarget());
// set up the timer action
activityMonitor = new Timer(200, new ActionListener() {
public void actionPerformed (ActionEvent event) {
int progress = theThread.getProgress();
// show progress
progressDialog.setProgress(progress);
// check if task is completed or canceled
if( progress==theThread.getTarget() || theThread.isInterrupted() || progressDialog.isCanceled ()) {
activityMonitor.stop();
progressDialog.close();
if( progress!=theThread.getTarget() ) {
theThread.interrupt();
onAnnotationAborted(theThread);
}
else {
onAnnotationCompleted(theThread);
}
}
}
});
activityMonitor.start();
// return control
return true;
}
示例5: scanAnnotationCascade
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public boolean scanAnnotationCascade(boolean ask, Vector<Scan> parentScans) {
if(setAnnotationOptions(ask)){
theApplication.haltInteractions();
showTopResults = false;
scanThread=new ScanAnnotationCascadeThread(parentScans,theWorkspace.getFragmentOptions(), theWorkspace.getAnnotationOptions());
scanThread.start();
progressDialog = new ProgressMonitor(theApplication,"Parent scans completed", null, 0, scanThread.getTarget());
// set up the timer action
activityMonitor = new Timer(200, new ActionListener() {
public void actionPerformed(ActionEvent event) {
int progress = scanThread.getProgress();
// show progress
progressDialog.setProgress(progress);
// check if task is completed or canceled
if (progress == scanThread.getTarget()
|| progressDialog.isCanceled()) {
System.err.println("Stopping activity monitor");
activityMonitor.stop();
progressDialog.close();
if (progress != scanThread.getTarget()) {
scanThread.interrupt();
onAnnotationAborted(scanThread);
} else {
onAnnotationCompleted(scanThread);
}
}
}
});
activityMonitor.start();
}
return true;
}
示例6: evaluateAndPlotPrivate2
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
private void evaluateAndPlotPrivate2(final String expr, final String map,
final String mapped_expr) {
final ProgressMonitor pm = new ProgressMonitor(this, "Plotting " + mapped_expr, null, 0, 1);
// final Object result = new JDPAEvaluator().evaluate(expr,pm);
Returner r = new Returner() {
@Override
public void returnResult(final Object result) {
pm.close();
if (null != result) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
setEvaluatedExpr(mapped_expr);
setEvaluatedObject(result);
}
});
}
}
};
Collection<? extends Evaluator> evaluators
= Lookup.getDefault().lookupAll(Evaluator.class);
for (Evaluator evaluator : evaluators) {
if (evaluator.isValid()) {
evaluator.evaluate(expr, map, pm, r, showGetters);
return;
}
}
DebugPlotPrint.printString("No valid evaluator found.");
}
示例7: go
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public HalfMesh2 go(List<Line> footprint, SkelGen skelGen, ProgressMonitor m ) {
this.skelGen = skelGen;
PaintThing.lookup.put( ColorRGBA.class, new ColorRGBAPainter() );
PaintThing.debug.clear();
SolverState SS;
greedyProfiles = false;
if ( FALSE ) {
try {
SS = (SolverState) new XStream().fromXML( new FileReader( new File( "/home/twak/data/bath/solver_state.xml" ) ) );
} catch ( FileNotFoundException e ) {
e.printStackTrace();
SS = null;
}
} else {
SS = buildFootprint( footprint, m, tweed.features, skelGen.blockGen );
dbgCountProfileEdges( SS );
if ( SS == null )
return null;
if ( FALSE ) {
PaintThing.debug.clear();
dbgShowProfiles( SS.mesh, SS.globalProfs, SS.profFit, "edge fit" );
SS.debugSolverResult();
m.close();
return SS.mesh;
}
solve( SS, m, skelGen.blockGen.getSolutionFile(), Long.MAX_VALUE );
}
if (greedyProfiles)
assignGreedyProfiles( SS );
if ( TRUE )
postProcesss(SS);
dbgCountProfileEdges( SS );
dbgShowProfiles( SS.mesh, SS.globalProfs, SS.profFit, "edge fit" );
if (FALSE) {
dbgShowProfiles( SS.mesh, null, SS.profFit, "postprocess" );
PaintThing.debug.put( 1, footprint );
SS.debugSolverResult();
}
return SS.mesh;
}
示例8: writeEEPROM
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
/**
* This is a BLOCKING write call to write the Cypress EEPROM. Max number of
* bytes is defined by {@link #EEPROM_SIZE}. Thread-safe.
*
* @param addr the starting address
* @param bytes the bytes to write
*/
synchronized public void writeEEPROM(int addr, byte[] bytes) throws HardwareInterfaceException {
log.info("writing EEPROM to addr=" + addr + " with " + bytes.length + " bytes");
if (bytes.length > this.EEPROM_SIZE) {
throw new RuntimeException(bytes.length + " is too many bytes for EEPROM to hold (" + EEPROM_SIZE + ")");
}
if ((addr < 0) || ((addr + bytes.length) > EEPROM_SIZE)) {
throw new RuntimeException(bytes.length + " is too many bytes for EEPROM to hold (" + EEPROM_SIZE + ") starting at address " + addr);
}
int result; // result of USBIO operations
USBIO_DATA_BUFFER dataBuffer = null;
USBIO_CLASS_OR_VENDOR_REQUEST vendorRequest = null;
int numChunks, index;
// make vendor request structure and populate it
vendorRequest = new USBIO_CLASS_OR_VENDOR_REQUEST();
vendorRequest.Request = VR_EEPROM; // this is EEPROM command, direction of vendor request defines download here
vendorRequest.Flags = UsbIoInterface.USBIO_SHORT_TRANSFER_OK;
vendorRequest.Type = UsbIoInterface.RequestTypeVendor; // this is a vendor, not generic USB, request
vendorRequest.Recipient = UsbIoInterface.RecipientDevice; // device (not endpoint, interface, etc) receives it
vendorRequest.RequestTypeReservedBits = 0; // set these bits to zero for Cypress-specific 'vendor request' rather that user defined
vendorRequest.Index = 0;
//send all but last chunk
vendorRequest.Value = (short) addr; //address to write to (starting)
dataBuffer = new USBIO_DATA_BUFFER(MAX_CONTROL_XFER_SIZE);
dataBuffer.setNumberOfBytesToTransfer(dataBuffer.Buffer().length);
index = 0;
numChunks = bytes.length / MAX_CONTROL_XFER_SIZE; // this is number of full chunks to send
ProgressMonitor progressMonitor = makeProgressMonitor("Writing " + numChunks + " " + MAX_CONTROL_XFER_SIZE + " byte chunks FX2 firmware - do not unplug!", 0, numChunks);
for (int i = 0; i < numChunks; i++) {
System.arraycopy(bytes, i * MAX_CONTROL_XFER_SIZE, dataBuffer.Buffer(), 0, MAX_CONTROL_XFER_SIZE);
result = gUsbIo.classOrVendorOutRequest(dataBuffer, vendorRequest);
if (result != USBIO_ERR_SUCCESS) {
close();
throw new HardwareInterfaceException("Error on downloading segment number " + i + " of EEPROM write: " + UsbIo.errorText(result));
}
vendorRequest.Value += MAX_CONTROL_XFER_SIZE; //change address of EEPROM write location
// can't cancel
if (progressMonitor.isCanceled()) {
progressMonitor = makeProgressMonitor("Writing FX2 firmware - do not unplug!", 0, numChunks);
progressMonitor.setMillisToDecideToPopup(0);
}
progressMonitor.setProgress(i);
progressMonitor.setNote(String.format("wrote %d of %d chunks of FX2 firmware", i, numChunks));
}
// now send final (short) chunk
int numBytesLeft = bytes.length % MAX_CONTROL_XFER_SIZE; // remainder
if (numBytesLeft > 0) {
dataBuffer = new USBIO_DATA_BUFFER(numBytesLeft);
dataBuffer.setNumberOfBytesToTransfer(dataBuffer.Buffer().length);
System.arraycopy(bytes, numChunks * MAX_CONTROL_XFER_SIZE, dataBuffer.Buffer(), 0, numBytesLeft);
// send remaining part of firmware
result = gUsbIo.classOrVendorOutRequest(dataBuffer, vendorRequest);
if (result != USBIO_ERR_SUCCESS) {
close();
throw new HardwareInterfaceException("Error on downloading final segment of EEPROM write: " + UsbIo.errorText(result) + "\nIs there an EEPROM? Does the device have firmware that can write the EEPROM?");
}
}
progressMonitor.close();
}
示例9: doImportTraitsFileImpl
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
private void doImportTraitsFileImpl(File file) {
Context context = KDSmartApplication.getInstance();
final ProgressMonitor monitor = new ProgressMonitor(TraitExplorerPanel.this, "Loading", "", 0, 100);
ProgressReporter progressReporter = new ProgressReporter() {
@Override
public void setProgressNote(String note) {
monitor.setNote(note);
}
@Override
public void setProgressMaximum(int max) {
monitor.setMaximum(max);
}
@Override
public void setProgressCount(int count) {
monitor.setProgress(count);
}
@Override
public void dismissProgress() {
monitor.close();
}
};
try {
Either<ImportError, TraitImportTransactions> either = offlineData.getKdxploreDatabase()
.getKDXploreKSmartDatabase().importTraitsFile(context, file, progressReporter);
if (either.isLeft()) {
ImportError ie = either.left();
MsgBox.error(TraitExplorerPanel.this, ie.getMessage("Import Traits"), "Import Failed");
} else {
TraitImportTransactions tit = either.right();
if (!tit.traitsToBeUpdated.isEmpty()) {
}
refreshTraitsTable();
StringBuilder sb = new StringBuilder("Import Result");
if (tit.nSkipped > 0) {
sb.append("\nSkipped ").append(tit.nSkipped);
}
if (!tit.traitsToBeAdded.isEmpty()) {
sb.append("\nAdded: ").append(tit.traitsToBeAdded.size());
}
if (!tit.traitsToBeUpdated.isEmpty()) {
sb.append("\nUpdated: ").append(tit.traitsToBeUpdated.size());
}
MsgBox.info(TraitExplorerPanel.this, sb.toString(), "Import Complete");
}
} finally {
progressReporter.dismissProgress();
}
}
示例10: runAnnotation
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
protected boolean runAnnotation(PeakList _peaks,
Collection<Glycan> _structures, Fragmenter _fragmenter,
AnnotationOptions _ann_opt) {
// start activity
theThread = new AnnotationThread(_peaks, _structures, _fragmenter,
_ann_opt);
theThread.start();
// launch progress dialog
progressDialog = new ProgressMonitor(theApplication,
"Matching peaks with fragments", null, 0, theThread.getTarget());
// set up the timer action
activityMonitor = new Timer(200, new ActionListener() {
public void actionPerformed(ActionEvent event) {
int progress = theThread.getProgress();
// show progress
progressDialog.setProgress(progress);
// check if task is completed or canceled
if (progress == theThread.getTarget()
|| progressDialog.isCanceled()) {
System.err.println("Stopping activity monitor");
activityMonitor.stop();
progressDialog.close();
if (progress != theThread.getTarget()) {
theThread.interrupt();
onAnnotationAborted(theThread);
} else {
onAnnotationCompleted(theThread);
}
}
}
});
System.err.println("Starting activity monitor");
activityMonitor.start();
// return control
return true;
}
示例11: tableChanged
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
@Override
public void tableChanged(TableModelEvent e) {
super.tableChanged(e);
if (e.getType() == DataTableModelEvent.CUSTOM_TABLE_MODEL_TYPE) {
DataTableModelEvent ec = (DataTableModelEvent) e;
// log("tableChanged: columnIndex: "+columnIndex+", firstRow = "+e.getFirstRow()+", lastRow = "+e.getLastRow()+", Type = "+e.getType()+", source = "+e.getSource());
// log("tableChange: this.mainWindow: "+this.mainWindow);
// log("TableModelEventIDs: Allcols:"+TableModelEvent.ALL_COLUMNS+", Delete:"+TableModelEvent.DELETE+", Insert:"+TableModelEvent.INSERT+", Header:"+TableModelEvent.HEADER_ROW+", Update:"+TableModelEvent.UPDATE);
boolean[] autofitRequired = ec.getAxisAutofitRequired();
boolean[] resetFiltersRequired = ec.getAxisResetFilterRequired();
boolean[] applyFiltersRequired = ec.getAxisApplyFiltersRequired();
final ProgressMonitor progressMonitor = new ProgressMonitor(this.getParent(), "", "Rebuilding charts", 0, this.mainWindow.getDataSheet().getParameterCount() - 1);
progressMonitor.setMillisToPopup(0);
for (int i = 0; i < this.mainWindow.getDataSheet().getParameterCount() && !progressMonitor.isCanceled(); i++) {
final int progress = i;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressMonitor.setProgress(progress);
}
});
if (autofitRequired[i]) {
// log("tableChanged: autofitRequired");
this.mainWindow.autofitAxisAllChartFrames(i);
}
if (resetFiltersRequired[i]) {
// log("tableChanged: resetFiltersRequired");
this.mainWindow.resetFiltersOnAxisAllChartFrames(i);
}
if (applyFiltersRequired[i]) {
// log("tableChanged: applyFiltersRequired");
this.mainWindow.refilterAllChartFrames(i);
}
}
if (ec.isChartRebuildRequired()) {
log("tableChanged: isChartRebuildRequired ");
this.mainWindow.rebuildAllChartFrames();
}
if (ec.isChartRepaintRequired()) {
log("tableChanged:isChartRepaintRequired ");
this.mainWindow.repaintAllChartFrames();
}
if (ec.isDataPanelUpdateRequired()) {
log("tableChanged:isDataPanelUpdateRequired ");
this.mainWindow.updateDataPanel();
}
progressMonitor.close();
}
}
示例12: installDataFromFiles
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
protected Document installDataFromFiles(Component parentComponent, File[] files, File directory,String datasetName,Sector bbox) throws Exception {
// Create a ProgressMonitor that will provide feedback on how
final ProgressMonitor progressMonitor = new ProgressMonitor(parentComponent, "Importing "+datasetName, null, 0, 100);
final AtomicInteger progress = new AtomicInteger(0);
final DataStoreProducer producer = getProducer(files,bbox,datasetName,progressMonitor,progress);
progressMonitor.setProgress(0);
// Configure a timer to check if the user has clicked the ProgressMonitor's "Cancel" button. If so, stop
// production as soon as possible. This just stops the production from completing; it doesn't clean up any state
// changes made during production,
java.util.Timer progressTimer = new java.util.Timer();
progressTimer.schedule(new TimerTask() {
public void run() {
progressMonitor.setProgress(progress.get());
if (progressMonitor.isCanceled()) {
producer.stopProduction();
this.cancel();
}
}
}, progressMonitor.getMillisToDecideToPopup(), 100L);
Document doc = null;
try {
// Install the file into the specified FileStore.
doc = ImportUtils.createDataStore(files, directory, producer,datasetName);
// Create a raster server configuration document if the installation was successful
// and we're not converting a WW.NET tile set to a WW Java tile set.
// The raster server document enables the layer or elevation model (created to display this data)
// to create tiles from the original sources at runtime.
if (doc != null && !(producer instanceof WWDotNetLayerSetConverter)) ImportUtils.createRasterServerConfigDoc(directory, producer);
// The user clicked the ProgressMonitor's "Cancel" button. Revert any change made during production, and
// discard the returned DataConfiguration reference.
if (progressMonitor.isCanceled()) {
doc = null;
producer.removeProductionState();
}
} finally {
// Remove the progress event listener from the DataStoreProducer. stop the progress timer, and signify to the
// ProgressMonitor that we're done.
// producer.removePropertyChangeListener(progressListener);TODO FIXME
producer.removeAllDataSources();
progressMonitor.close();
progressTimer.cancel();
}
return doc;
}
示例13: translate
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
/**
* Change the IMC definitions of a given LSF file, generates a new one
* @param originalDir The folder of the original LSF file
* @param destinationDir The destination folder, containing the new IMC definitions
* @param messagesToFilter Messages to filtered out (optional)
* @param m ProgressMonitor to be updated according to the progress of this process (optional)
* @throws Exception In case some file cannot be read / written to.
*/
public static void translate(File originalDir, File destinationDir, Vector<String> messagesToFilter, ProgressMonitor m) throws Exception {
if (m != null)
m.setMaximum(100);
if (messagesToFilter == null)
messagesToFilter = new Vector<String>();
LsfIndex index = new LsfIndex(new File(originalDir, "Data.lsf"));
IMCDefinition destDefs = new IMCDefinition(new FileInputStream(new File(destinationDir, "IMC.xml")));
FileOutputStream fos = new FileOutputStream(new File(destinationDir, "Data.lsf"));
int lastPercent = -1;
System.out.println("Translating from "+originalDir+" to "+destinationDir);
for (int i = 0; i < index.getNumberOfMessages(); i++) {
if (messagesToFilter.contains(index.getDefinitions().getMessageName(index.typeOf(i))))
continue;
IMCMessage original = index.getMessage(i);
if (!destDefs.messageExists(original.getAbbrev())) {
System.err.println("Dropping message "+original.getAbbrev()+" because it doesn't exists in destination IMC.");
continue;
}
IMCMessage result = original.cloneMessage(destDefs);
destDefs.serialize(result, fos);
int percent = (i*100 / index.getNumberOfMessages());
if (percent != lastPercent) {
if (m != null) {
m.setNote(percent+"% done...");
m.setProgress(percent);
}
else
System.out.println(percent+"% done...");
lastPercent = percent;
}
}
if (m != null)
m.close();
fos.close();
}
示例14: progess
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
/**
* @param digest 文件数字签证操作类.
* @param filename 文件名称.
* @param filesize 文件大小(单位:bytes).
*/
private void progess(final Thread calThread, final FileDigitalSignatures digest,
String filename, final long filesize) {
String messae = resourceBundle.getString("progressmonitor.readingFile") + filename + "...";
final int maxScale = 100;
final ProgressMonitor readFileProgressMonitor = new ProgressMonitor(
FileDigitalSignaturesGui.this, messae, null, 0, maxScale);
Thread progessThread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
// 处理进度条的取消动作
if (readFileProgressMonitor.isCanceled()) {
readFileProgressMonitor.close();
calThread.interrupt();
calculateBtn.setEnabled(true);
break;
}
if (digest.getFilesize() == digest.getReadsize()
&& 0 != digest.getFilesize()
&& 0 != digest.getReadsize()) {
readFileProgressMonitor.setProgress(maxScale);
readFileProgressMonitor.setNote(resourceBundle.getString("progressmonitor.complete") + "100%");
break;
}
int scale = (int) ((digest.getReadsize() / filesize) * 100);
readFileProgressMonitor.setProgress(scale);
readFileProgressMonitor.setNote(resourceBundle.getString("progressmonitor.complete") + scale + "%");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
}
readFileProgressMonitor.close();
}
});
progessThread.start();
}