List of usage examples for javax.swing ProgressMonitor isCanceled
public boolean isCanceled()
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Load the provided file as an ontology replacing any assertions currently * in the assertions text area.//from ww w . j ava 2s . c o m * * @return The message to be presented on the status line */ private String loadOntologyFile() { final int chunkSize = 32000; StringBuilder allData; char[] chunk; long totalBytesRead = 0; int chunksRead = 0; int maxChunks; int bytesRead = -1; ProgressMonitor monitor = null; Reader reader = null; String message; boolean loadCanceled = false; if (rdfFileSource.isFile()) { lastDirectoryUsed = rdfFileSource.getBackingFile().getParentFile(); } assertionsInput.setText(""); invalidateModel(false); allData = new StringBuilder(); chunk = new char[chunkSize]; setStatus("Loading file " + rdfFileSource.getAbsolutePath()); if (rdfFileSource.length() > 0 && rdfFileSource.length() < MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA) { maxChunks = (int) (rdfFileSource.length() / chunkSize); } else { maxChunks = (int) (MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA / chunkSize); } if (rdfFileSource.length() % chunkSize > 0) { ++maxChunks; } // Assume the file can be loaded hasIncompleteAssertionsInput = false; monitor = new ProgressMonitor(this, "Loading assertions from " + rdfFileSource.getName(), "0 bytes read", 0, maxChunks); try { reader = new InputStreamReader(rdfFileSource.getInputStream()); while (!loadCanceled && (rdfFileSource.isUrl() || chunksRead < maxChunks) && (bytesRead = reader.read(chunk)) > -1) { totalBytesRead += bytesRead; chunksRead = (int) (totalBytesRead / chunk.length); if (chunksRead < maxChunks) { allData.append(chunk, 0, bytesRead); } if (chunksRead >= maxChunks) { monitor.setMaximum(chunksRead + 1); } monitor.setProgress(chunksRead); monitor.setNote("Read " + INTEGER_COMMA_FORMAT.format(totalBytesRead) + (rdfFileSource.isFile() ? " of " + INTEGER_COMMA_FORMAT.format(rdfFileSource.length()) : " bytes") + (chunksRead >= maxChunks ? " (Determining total file size)" : "")); loadCanceled = monitor.isCanceled(); } if (!loadCanceled && rdfFileSource.isUrl()) { rdfFileSource.setLength(totalBytesRead); } if (!loadCanceled && rdfFileSource.length() > MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA) { // The entire file was not loaded hasIncompleteAssertionsInput = true; } if (hasIncompleteAssertionsInput) { StringBuilder warningMessage; warningMessage = new StringBuilder(); warningMessage.append("The file is too large to display. However the entire file will be loaded\n"); warningMessage.append("into the model when it is built.\n\nDisplay size limit (bytes): "); warningMessage.append(INTEGER_COMMA_FORMAT.format(MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA)); if (rdfFileSource.isFile()) { warningMessage.append("\nFile size (bytes):"); warningMessage.append(INTEGER_COMMA_FORMAT.format(rdfFileSource.length())); } warningMessage.append("\n\n"); warningMessage.append("Note that the assersions text area will not permit editing\n"); warningMessage.append("of the partially loaded file and the 'save assertions' menu\n"); warningMessage.append("option will be disabled. These limitations are enabled\n"); warningMessage.append("to prevent the accidental loss of information from the\n"); warningMessage.append("source assertions file."); JOptionPane.showMessageDialog(this, warningMessage.toString(), "Max Display Size Reached", JOptionPane.WARNING_MESSAGE); // Add text to the assertions text area to highlight the fact that the // entire file was not loaded into the text area allData.insert(0, "# First " + INTEGER_COMMA_FORMAT.format(MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA) + " of " + INTEGER_COMMA_FORMAT.format(rdfFileSource.length()) + " bytes displayed\n\n"); allData.insert(0, "# INCOMPLETE VERSION of the file: " + rdfFileSource.getAbsolutePath() + "\n"); allData.append("\n\n# INCOMPLETE VERSION of the file: " + rdfFileSource.getAbsolutePath() + "\n"); allData.append("# First " + INTEGER_COMMA_FORMAT.format(MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA) + " of " + INTEGER_COMMA_FORMAT.format(rdfFileSource.length()) + " bytes displayed\n"); } // Set the loaded assertions into the text area, cleaning up Windows \r\n // endings, if found if (!loadCanceled) { assertionsInput.setText(allData.toString().replaceAll("\r\n", "\n")); assertionsInput.setSelectionEnd(0); assertionsInput.setSelectionStart(0); assertionsInput.moveCaretPosition(0); assertionsInput.scrollRectToVisible(new Rectangle(0, 0, 1, 1)); message = "Loaded file" + (hasIncompleteAssertionsInput ? " (incomplete)" : "") + ": " + rdfFileSource.getName(); addRecentAssertedTriplesFile(rdfFileSource); // Select the assertions tab SwingUtilities.invokeLater(new Runnable() { public void run() { tabbedPane.setSelectedIndex(TAB_NUMBER_ASSERTIONS); setFocusOnCorrectTextArea(); } }); } else { message = "Assertions file load canceled by user"; } } catch (Throwable throwable) { setStatus("Unable to load file: " + rdfFileSource.getName()); JOptionPane.showMessageDialog(this, "Error: Unable to read file\n\n" + rdfFileSource.getAbsolutePath() + "\n\n" + throwable.getMessage(), "Error Reading File", JOptionPane.ERROR_MESSAGE); LOGGER.error("Unable to load the file: " + rdfFileSource.getAbsolutePath(), throwable); message = "Unable to load the file: " + rdfFileSource.getAbsolutePath(); } finally { if (reader != null) { try { reader.close(); } catch (Throwable throwable) { LOGGER.error("Unable to close input file", throwable); } } if (monitor != null) { monitor.close(); } } return message; }
From source file:com.marginallyclever.makelangelo.MainGUI.java
protected boolean LoadDXF(String filename) { if (ChooseImageConversionOptions(true) == false) return false; // where to save temp output file? final String destinationFile = GetTempDestinationFile(); final String srcFile = filename; TabToLog();//from w w w . j a v a 2 s . co m final ProgressMonitor pm = new ProgressMonitor(null, translator.get("Converting"), "", 0, 100); pm.setProgress(0); pm.setMillisToPopup(0); final SwingWorker<Void, Void> s = new SwingWorker<Void, Void>() { public boolean ok = false; @SuppressWarnings("unchecked") @Override public Void doInBackground() { Log("<font color='green'>" + translator.get("Converting") + " " + destinationFile + "</font>\n"); Parser parser = ParserBuilder.createDefaultParser(); double dxf_x2 = 0; double dxf_y2 = 0; OutputStreamWriter out = null; try { out = new OutputStreamWriter(new FileOutputStream(destinationFile), "UTF-8"); DrawingTool tool = machineConfiguration.GetCurrentTool(); out.write(machineConfiguration.GetConfigLine() + ";\n"); out.write(machineConfiguration.GetBobbinLine() + ";\n"); out.write("G00 G90;\n"); tool.WriteChangeTo(out); tool.WriteOff(out); parser.parse(srcFile, DXFParser.DEFAULT_ENCODING); DXFDocument doc = parser.getDocument(); Bounds b = doc.getBounds(); double width = b.getMaximumX() - b.getMinimumX(); double height = b.getMaximumY() - b.getMinimumY(); double cx = (b.getMaximumX() + b.getMinimumX()) / 2.0f; double cy = (b.getMaximumY() + b.getMinimumY()) / 2.0f; double sy = machineConfiguration.GetPaperHeight() * 10 / height; double sx = machineConfiguration.GetPaperWidth() * 10 / width; double scale = (sx < sy ? sx : sy) * machineConfiguration.paper_margin; sx = scale * (machineConfiguration.reverseForGlass ? -1 : 1); // count all entities in all layers Iterator<DXFLayer> layer_iter = (Iterator<DXFLayer>) doc.getDXFLayerIterator(); int entity_total = 0; int entity_count = 0; while (layer_iter.hasNext()) { DXFLayer layer = (DXFLayer) layer_iter.next(); Log("<font color='yellow'>Found layer " + layer.getName() + "</font>\n"); Iterator<String> entity_iter = (Iterator<String>) layer.getDXFEntityTypeIterator(); while (entity_iter.hasNext()) { String entity_type = (String) entity_iter.next(); List<DXFEntity> entity_list = (List<DXFEntity>) layer.getDXFEntities(entity_type); Log("<font color='yellow'>+ Found " + entity_list.size() + " of type " + entity_type + "</font>\n"); entity_total += entity_list.size(); } } // set the progress meter pm.setMinimum(0); pm.setMaximum(entity_total); // convert each entity layer_iter = doc.getDXFLayerIterator(); while (layer_iter.hasNext()) { DXFLayer layer = (DXFLayer) layer_iter.next(); Iterator<String> entity_type_iter = (Iterator<String>) layer.getDXFEntityTypeIterator(); while (entity_type_iter.hasNext()) { String entity_type = (String) entity_type_iter.next(); List<DXFEntity> entity_list = layer.getDXFEntities(entity_type); if (entity_type.equals(DXFConstants.ENTITY_TYPE_LINE)) { for (int i = 0; i < entity_list.size(); ++i) { pm.setProgress(entity_count++); DXFLine entity = (DXFLine) entity_list.get(i); Point start = entity.getStartPoint(); Point end = entity.getEndPoint(); double x = (start.getX() - cx) * sx; double y = (start.getY() - cy) * sy; double x2 = (end.getX() - cx) * sx; double y2 = (end.getY() - cy) * sy; // is it worth drawing this line? double dx = x2 - x; double dy = y2 - y; if (dx * dx + dy * dy < tool.GetDiameter() / 2.0) { continue; } dx = dxf_x2 - x; dy = dxf_y2 - y; if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) { if (tool.DrawIsOn()) { tool.WriteOff(out); } tool.WriteMoveTo(out, (float) x, (float) y); } if (tool.DrawIsOff()) { tool.WriteOn(out); } tool.WriteMoveTo(out, (float) x2, (float) y2); dxf_x2 = x2; dxf_y2 = y2; } } else if (entity_type.equals(DXFConstants.ENTITY_TYPE_SPLINE)) { for (int i = 0; i < entity_list.size(); ++i) { pm.setProgress(entity_count++); DXFSpline entity = (DXFSpline) entity_list.get(i); entity.setLineWeight(30); DXFPolyline polyLine = DXFSplineConverter.toDXFPolyline(entity); boolean first = true; for (int j = 0; j < polyLine.getVertexCount(); ++j) { DXFVertex v = polyLine.getVertex(j); double x = (v.getX() - cx) * sx; double y = (v.getY() - cy) * sy; double dx = dxf_x2 - x; double dy = dxf_y2 - y; if (first == true) { first = false; if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) { // line does not start at last tool location, lift and move. if (tool.DrawIsOn()) { tool.WriteOff(out); } tool.WriteMoveTo(out, (float) x, (float) y); } // else line starts right here, do nothing. } else { // not the first point, draw. if (tool.DrawIsOff()) tool.WriteOn(out); if (j < polyLine.getVertexCount() - 1 && dx * dx + dy * dy < tool.GetDiameter() / 2.0) continue; // less than 1mm movement? Skip it. tool.WriteMoveTo(out, (float) x, (float) y); } dxf_x2 = x; dxf_y2 = y; } } } else if (entity_type.equals(DXFConstants.ENTITY_TYPE_POLYLINE)) { for (int i = 0; i < entity_list.size(); ++i) { pm.setProgress(entity_count++); DXFPolyline entity = (DXFPolyline) entity_list.get(i); boolean first = true; for (int j = 0; j < entity.getVertexCount(); ++j) { DXFVertex v = entity.getVertex(j); double x = (v.getX() - cx) * sx; double y = (v.getY() - cy) * sy; double dx = dxf_x2 - x; double dy = dxf_y2 - y; if (first == true) { first = false; if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) { // line does not start at last tool location, lift and move. if (tool.DrawIsOn()) { tool.WriteOff(out); } tool.WriteMoveTo(out, (float) x, (float) y); } // else line starts right here, do nothing. } else { // not the first point, draw. if (tool.DrawIsOff()) tool.WriteOn(out); if (j < entity.getVertexCount() - 1 && dx * dx + dy * dy < tool.GetDiameter() / 2.0) continue; // less than 1mm movement? Skip it. tool.WriteMoveTo(out, (float) x, (float) y); } dxf_x2 = x; dxf_y2 = y; } } } } } // entities finished. Close up file. tool.WriteOff(out); tool.WriteMoveTo(out, 0, 0); ok = true; } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { if (out != null) out.close(); } catch (IOException e) { e.printStackTrace(); } } pm.setProgress(100); return null; } @Override public void done() { pm.close(); Log("<font color='green'>" + translator.get("Finished") + "</font>\n"); PlayConversionFinishedSound(); if (ok) { LoadGCode(destinationFile); TabToDraw(); } Halt(); } }; s.addPropertyChangeListener(new PropertyChangeListener() { // Invoked when task's progress property changes. public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); pm.setProgress(progress); String message = String.format("%d%%\n", progress); pm.setNote(message); if (s.isDone()) { Log("<font color='green'>" + translator.get("Finished") + "</font>\n"); } else if (s.isCancelled() || pm.isCanceled()) { if (pm.isCanceled()) { s.cancel(true); } Log("<font color='green'>" + translator.get("Cancelled") + "</font>\n"); } } } }); s.execute(); return true; }
From source file:plugin.notes.gui.NotesView.java
/** * Writes out a directory to a zipoutputstream * *@param out Zip output stream to write to *@param parentDir parent dir of whole structure to be written out *@param currentDir dir to be zipped up *@param pm progress meter that will display the progress *@param progress progress up to this dir *@return current progress *@exception IOException write or read failed for some reason *//*from w ww. ja v a2 s . c om*/ private int writeNotesDir(ZipOutputStream out, File parentDir, File currentDir, ProgressMonitor pm, int progress) throws IOException { byte[] buffer = new byte[4096]; int bytes_read; int returnValue = progress; for (File f : currentDir.listFiles()) { if (pm.isCanceled()) { return 0; } if (f.isDirectory()) { returnValue = writeNotesDir(out, parentDir, f, pm, returnValue); } else { FileInputStream in = new FileInputStream(f); try { String parentPath = parentDir.getParentFile().getAbsolutePath(); ZipEntry entry = new ZipEntry(f.getAbsolutePath().substring(parentPath.length() + 1)); out.putNextEntry(entry); while ((bytes_read = in.read(buffer)) != -1) { out.write(buffer, 0, bytes_read); } } finally { try { in.close(); } catch (IOException e) { //TODO: Should this really be ignored? } } returnValue++; } } pm.setProgress(returnValue); return returnValue; }
From source file:richtercloud.document.scanner.gui.MainPanel.java
/** * Exceptions are handled here in order to maximize code reusage although * this requires check if {@code progressMonitor} is used (not {@code null}) * or not./*from w w w. j a v a 2 s . c om*/ * @param images * @param documentFile * @return the created {@link OCRSelectComponentScrollPane} */ private OCRSelectComponent addDocumentRoutine(List<BufferedImage> images, File documentFile, Object entityToEdit, ProgressMonitor progressMonitor) throws DocumentAddException { OCRSelectComponent retValue = null; try { List<OCRSelectPanel> panels = new LinkedList<>(); if (images != null) { for (BufferedImage image : images) { @SuppressWarnings("serial") OCRSelectPanel panel = new OCRSelectPanel(image) { @Override public void mouseReleased(MouseEvent evt) { super.mouseReleased(evt); if (this.getDragStart() != null && !this.getDragStart().equals(this.getDragEnd())) { MainPanel.this.handleOCRSelection(); } } }; panels.add(panel); } } OCRSelectPanelPanel oCRSelectPanelPanel = new OCRSelectPanelPanel(panels, documentFile); OCRResultPanelFetcher oCRResultPanelFetcher = new DocumentTabOCRResultPanelFetcher(oCRSelectPanelPanel, oCREngineFactory); ScanResultPanelFetcher scanResultPanelFetcher = new MainPanelScanResultPanelFetcher( oCRSelectPanelPanel); AmountMoneyMappingFieldHandlerFactory embeddableFieldHandlerFactory = new AmountMoneyMappingFieldHandlerFactory( amountMoneyUsageStatisticsStorage, amountMoneyCurrencyStorage, amountMoneyExchangeRateRetriever, messageHandler); FieldHandler embeddableFieldHandler = new MappingFieldHandler( embeddableFieldHandlerFactory.generateClassMapping(), embeddableFieldHandlerFactory.generatePrimitiveMapping()); ElementCollectionTypeHandler elementCollectionTypeHandler = new ElementCollectionTypeHandler( typeHandlerMapping, typeHandlerMapping, messageHandler, embeddableFieldHandler); JPAAmountMoneyMappingFieldHandlerFactory jPAAmountMoneyMappingFieldHandlerFactory = JPAAmountMoneyMappingFieldHandlerFactory .create(entityManager, INITIAL_QUERY_LIMIT_DEFAULT, messageHandler, amountMoneyUsageStatisticsStorage, amountMoneyCurrencyStorage, amountMoneyExchangeRateRetriever, BIDIRECTIONAL_HELP_DIALOG_TITLE); ToManyTypeHandler toManyTypeHandler = new ToManyTypeHandler(entityManager, messageHandler, typeHandlerMapping, typeHandlerMapping, BIDIRECTIONAL_HELP_DIALOG_TITLE); ToOneTypeHandler toOneTypeHandler = new ToOneTypeHandler(entityManager, messageHandler, BIDIRECTIONAL_HELP_DIALOG_TITLE); FieldHandler fieldHandler = new DocumentScannerFieldHandler( jPAAmountMoneyMappingFieldHandlerFactory.generateClassMapping(), embeddableFieldHandlerFactory.generateClassMapping(), embeddableFieldHandlerFactory.generatePrimitiveMapping(), elementCollectionTypeHandler, toManyTypeHandler, toOneTypeHandler, idGenerator, messageHandler, fieldRetriever, oCRResultPanelFetcher, scanResultPanelFetcher, this.documentScannerConf, oCRProgressMonitorParent //oCRProgressMonitorParent ); Map<Class<?>, ReflectionFormPanel<?>> reflectionFormPanelMap = new HashMap<>(); Set<Class<?>> entityClasses0; if (entityToEdit == null) { for (Class<?> entityClass : entityClasses) { ReflectionFormPanel reflectionFormPanel; try { reflectionFormPanel = reflectionFormBuilder.transformEntityClass(entityClass, null, //entityToUpdate false, //editingMode fieldHandler); reflectionFormPanelMap.put(entityClass, reflectionFormPanel); } catch (FieldHandlingException ex) { String message = String.format( "An exception during creation of components occured (details: %s)", ex.getMessage()); JOptionPane.showMessageDialog(MainPanel.this, message, DocumentScanner.generateApplicationWindowTitle("Exception", DocumentScanner.APP_NAME, DocumentScanner.APP_VERSION), JOptionPane.WARNING_MESSAGE); LOGGER.error(message, ex); throw ex; } } entityClasses0 = entityClasses; } else { ReflectionFormPanel reflectionFormPanel = reflectionFormBuilder.transformEntityClass( entityToEdit.getClass(), entityToEdit, true, //editingMode fieldHandler); reflectionFormPanelMap.put(entityToEdit.getClass(), reflectionFormPanel); entityClasses0 = new HashSet<Class<?>>(Arrays.asList(entityToEdit.getClass())); } retValue = new OCRSelectComponent(oCRSelectPanelPanel); OCRPanel oCRPanel = new OCRPanel(entityClasses0, reflectionFormPanelMap, valueSetterMapping, entityManager, messageHandler, reflectionFormBuilder, documentScannerConf); EntityPanel entityPanel = new EntityPanel(entityClasses0, primaryClassSelection, reflectionFormPanelMap, valueSetterMapping, oCRResultPanelFetcher, scanResultPanelFetcher, amountMoneyUsageStatisticsStorage, amountMoneyCurrencyStorage); if (progressMonitor == null || !progressMonitor.isCanceled()) { documentSwitchingMap.put(retValue, new ImmutablePair<>(oCRPanel, entityPanel)); } return retValue; } catch (HeadlessException | IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | InvocationTargetException ex) { if (progressMonitor != null) { progressMonitor.close(); } throw new DocumentAddException(ex); } catch (Throwable ex) { //This dramatically facilitates debugging since Java //debugger has a lot of problems to halt at uncatched //exceptions and a lot of JVMs don't provide debugging //symbols. String message = "An unexpected exception occured " + "during initialization (see stacktrace " + "for details)"; LOGGER.error(message, ex); if (progressMonitor != null) { progressMonitor.close(); } JOptionPane.showMessageDialog(MainPanel.this, //parentComponent String.format( "<html>%s. Please consider filing a " + "bug at <a href=\"%s\">%s</a>. Stacktrace: %s</html>", message, DocumentScanner.BUG_URL, DocumentScanner.BUG_URL, ExceptionUtils.getFullStackTrace(ex)), generateApplicationWindowTitle("An exception occured", APP_NAME, APP_VERSION), JOptionPane.ERROR_MESSAGE); } return retValue; }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Executes all the queries/* www . j ava 2 s. co m*/ */ private void runAllQueries() { int numExecutions, numQueries; int execution, query; ProgressMonitor monitor; boolean canceled; java.util.Date start; int elapsed; long remaining; int hours, minutes, seconds; numQueries = querySelection.getModel().getSize(); try { numExecutions = Integer .parseInt(JOptionPane.showInputDialog(this, Resources.getString("dlgAllQueriesText"), Resources.getString("dlgAllQueriesTitle"), JOptionPane.QUESTION_MESSAGE)); } catch (Exception any) { numExecutions = 0; } messageOut(Resources.getString("msgNumExecutions", numExecutions + "")); monitor = new ProgressMonitor(this, Resources.getString("dlgRunAllQueriesProgressTitle"), Resources.getString("dlgRunAllQueriesProgressNote", "0", numExecutions + "", "0", numQueries + ""), 0, numQueries * Math.abs(numExecutions)); getContentPane().setCursor(new Cursor(Cursor.WAIT_CURSOR)); if (numExecutions < 0) { numExecutions = Math.abs(numExecutions); for (query = 0; !monitor.isCanceled() && query < numQueries; ++query) { querySelection.setSelectedIndex(query); elapsed = -1; for (execution = 0; !monitor.isCanceled() && execution < numExecutions; ++execution) { monitor.setProgress(query * numExecutions + execution); if (elapsed <= 0) { monitor.setNote(Resources.getString("dlgRunAllQueriesProgressNote", (execution + 1) + "", numExecutions + "", (query + 1) + "", numQueries + "")); } else { remaining = elapsed * ((numExecutions * (numQueries - (query + 1))) + (numExecutions - execution)); hours = (int) (remaining / SECONDS_PER_HOUR); remaining -= hours * SECONDS_PER_HOUR; minutes = (int) (remaining / SECONDS_PER_MINUTE); remaining -= minutes * SECONDS_PER_MINUTE; seconds = (int) remaining; monitor.setNote(Resources.getString("dlgRunAllQueriesProgressNoteWithRemainTime", (execution + 1) + "", numExecutions + "", (query + 1) + "", numQueries + "", Utility.formattedNumber(hours, "00"), Utility.formattedNumber(minutes, "00"), Utility.formattedNumber(seconds, "00"))); } messageOut(Resources.getString("dlgRunAllQueriesProgressNote", (execution + 1) + "", numExecutions + "", (query + 1) + "", numQueries + "")); start = new java.util.Date(); processStatement(true); elapsed = (int) ((new java.util.Date().getTime() - start.getTime()) / 1000); } } } else { elapsed = -1; for (execution = 0; !monitor.isCanceled() && execution < numExecutions; ++execution) { start = new java.util.Date(); for (query = 0; !monitor.isCanceled() && query < numQueries; ++query) { querySelection.setSelectedIndex(query); monitor.setProgress(execution * numQueries + query); if (elapsed <= 0) { monitor.setNote(Resources.getString("dlgRunAllQueriesProgressNote", (execution + 1) + "", numExecutions + "", (query + 1) + "", numQueries + "")); } else { remaining = elapsed * (numExecutions - execution); hours = (int) (remaining / SECONDS_PER_HOUR); remaining -= hours * SECONDS_PER_HOUR; minutes = (int) (remaining / SECONDS_PER_MINUTE); remaining -= minutes * SECONDS_PER_MINUTE; seconds = (int) remaining; monitor.setNote(Resources.getString("dlgRunAllQueriesProgressNoteWithRemainTime", (execution + 1) + "", numExecutions + "", (query + 1) + "", numQueries + "", Utility.formattedNumber(hours, "00"), Utility.formattedNumber(minutes, "00"), Utility.formattedNumber(seconds, "00"))); } messageOut(Resources.getString("dlgRunAllQueriesProgressNote", (execution + 1) + "", numExecutions + "", (query + 1) + "", numQueries + "")); processStatement(true); } elapsed = (int) ((new java.util.Date().getTime() - start.getTime()) / 1000); } } canceled = monitor.isCanceled(); monitor.close(); getContentPane().setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (canceled) { userMessage(Resources.getString("dlgExecutionsCanceledText"), Resources.getString("dlgExecutionsCanceledTitle"), JOptionPane.WARNING_MESSAGE); } else if (numExecutions != 0) { userMessage(Resources.getString("dlgExecutionsCompletedText"), Resources.getString("dlgExecutionsCompletedTitle"), JOptionPane.INFORMATION_MESSAGE); } else { userMessage(Resources.getString("dlgExecutionsNoneText"), Resources.getString("dlgExecutionsNoneTitle"), JOptionPane.INFORMATION_MESSAGE); } }