List of usage examples for javax.swing ProgressMonitor setProgress
@SuppressWarnings("deprecation") public void setProgress(int nv)
From source file:oct.analysis.application.dat.OCTAnalysisManager.java
/** * This method will take care of interacting with the user in determining * where the fovea is within the OCT. It first lets the user inspect the * automatically identified locations where the fovea may be and then choose * the selection that is at the fovea. If none of the automated findings are * at the fovea the user has the option to manual specify it's location. * Finally, the chosen X coordinate (within the OCT) of the fovea is set in * the manager and can be obtained via the getFoveaCenterXPosition getter. * * @param fullAutoMode find the fovea automatically without user input when * true, otherwise find the fovea in semi-automatic mode involving user * interaction//from w ww. j a v a 2s .com */ public void findCenterOfFovea(boolean fullAutoMode) throws InterruptedException, ExecutionException { //disable clicking other components while processing by enabling glass pane JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(imgPanel); Component glassPane = topFrame.getGlassPane(); glassPane.setVisible(true); //monitor progress of finding the fovea ProgressMonitor pm = new ProgressMonitor(imgPanel, "Analyzing OCT for fovea...", "", 0, 100); pm.setMillisToDecideToPopup(0); pm.setMillisToPopup(100); pm.setProgress(0); FoveaFindingTask fvtask = new FoveaFindingTask(!fullAutoMode, glassPane); fvtask.addPropertyChangeListener((PropertyChangeEvent evt) -> { if ("progress".equals(evt.getPropertyName())) { int progress1 = (Integer) evt.getNewValue(); pm.setProgress(progress1); } }); fvtask.execute(); }
From source file:org.archiviststoolkit.mydomain.DomainAccessObjectImpl.java
/** * Add a group of instances.// w w w. j av a 2s . c om * * @param collection the objects to add * @throws PersistenceException fails if we cannot persist the instance */ public final void addGroup(final Collection collection, Component parent) throws PersistenceException { Session session = SessionFactory.getInstance() .openSession(new AuditInterceptor(ApplicationFrame.getInstance().getCurrentUser())); DomainObject domainObject = null; try { Iterator iterator = collection.iterator(); int numberOfRecords = collection.size(); ProgressMonitor monitor = new ProgressMonitor(parent, "Saving Records", null, 0, numberOfRecords); int count = 0; while (iterator.hasNext()) { domainObject = (DomainObject) iterator.next(); updateClassSpecific(domainObject, session); session.saveOrUpdate(domainObject); monitor.setProgress(count++); } monitor.close(); session.flush(); session.connection().commit(); } catch (HibernateException hibernateException) { throw new PersistenceException("failed to add, class: " + this.getClass() + " object: " + domainObject, hibernateException); } catch (Exception sqlException) { throw new PersistenceException("failed to add, class: " + this.getClass() + " object: " + domainObject, sqlException); } // HibernateUtil.closeSession(); SessionFactory.getInstance().closeSession(session); this.notifyListeners(new DomainAccessEvent(DomainAccessEvent.INSERTGROUP, collection)); }
From source file:org.ecoinformatics.seek.ecogrid.quicksearch.GetMetadataAction.java
/** * Invoked when an action occurs. It will transfer the original metadata * into a html file. The namespace will be the key to find stylesheet. If no * sytlesheet found, metadata will be null. * //from w ww. j a v a 2s. co m * @param e * ActionEvent */ public void actionPerformed(ActionEvent e) { super.actionPerformed(e); NamedObj object = getTarget(); if (object instanceof ResultRecord) { this.item = (ResultRecord) object; } if (item == null) { JOptionPane.showMessageDialog(null, "There is no metadata associated with this component."); return; } ProgressMonitor progressMonitor = new ProgressMonitor(null, "Acquiring Metadata ", "", 0, 5); progressMonitor.setMillisToDecideToPopup(100); progressMonitor.setMillisToPopup(10); progressMonitor.setProgress(0); this.metadataSource = item.getFullRecord(); progressMonitor.setProgress(1); this.nameSpace = item.getNamespace(); progressMonitor.setProgress(2); this.htmlFileName = item.getRecordId(); //System.out.println("the html file name is ====== "+htmlFileName); progressMonitor.setProgress(3); if (configuration == null) { configuration = getConfiguration(); } if (metadataSource != null && nameSpace != null && htmlFileName != null && configuration != null) { if (htmlFileName.endsWith(XMLFILEEXTENSION)) { htmlFileName = htmlFileName + HTMLFILEEXTENSION; } try { progressMonitor.setProgress(4); metadata = StaticUtil.getMetadataHTMLurl(metadataSource, nameSpace, htmlFileName); //System.out.println("before open html page"); configuration.openModel(null, metadata, metadata.toExternalForm()); progressMonitor.setProgress(5); //System.out.println("after open html page"); progressMonitor.close(); } catch (Exception ee) { log.debug("The error to get metadata html ", ee); } } }
From source file:org.mbari.aved.ui.classifier.knowledgebase.SearchableConceptTreePanel.java
/** * Perfroms the database lookup of all matching Concepts. * @param text/*w w w . j a va 2 s. c om*/ * @param useGlobSearch */ private void loadNodes(final String text, final boolean useGlobSearch) { Collection matches = null; try { if (useGlobSearch) { if (!cachedGlobSearches.contains(text)) { matches = LWConceptNameDAO.getInstance().findNamesBySubString(text); cachedGlobSearches.add(text); cachedWordSearches.add(text); } } else { if (!cachedWordSearches.contains(text)) { matches = LWConceptNameDAO.getInstance().findNamesStartingWith(text); cachedWordSearches.add(text); } } } catch (DAOException e) { if (log.isErrorEnabled()) { log.error("Database lookup of " + text + " failed", e); } } /* * If we loaded the matched names from the database then we need * to open the Concept such that it gets cached under the root * concept. */ if (matches != null) { final ProgressMonitor progressMonitor = new ProgressMonitor(AppFrameDispatcher.getFrame(), "Loading search results for '" + text + "'", "", 0, matches.size()); int n = 0; for (Iterator i = matches.iterator(); i.hasNext();) { n++; final IConceptName cn = (IConceptName) i.next(); progressMonitor.setProgress(n); progressMonitor.setNote("Loading '" + cn.getName() + "'"); /* * Have to open the node in a seperate thread for the * progress monitor to update. Here we're using foxtrot. */ Worker.post(new Job() { public Object run() { openNode((Concept) cn.getConcept()); return null; } }); } progressMonitor.close(); } }
From source file:plugin.notes.gui.NotesView.java
/** * Opens a .gmn file/* w w w . j a va 2 s .c o m*/ * *@param notesFile .gmn file to open */ private void openGMN(File notesFile) { try { Object obj = notesTree.getLastSelectedPathComponent(); if (obj instanceof NotesTreeNode) { NotesTreeNode node = (NotesTreeNode) obj; if (node != root) { int choice = JOptionPane.showConfirmDialog(this, "Importing note " + notesFile.getName() + " into a node other then root, Continue?", "Importing to a node other then root", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } } InputStream in = new BufferedInputStream(new FileInputStream(notesFile)); ZipInputStream zin = new ZipInputStream(in); ZipEntry e; ProgressMonitor pm = new ProgressMonitor(GMGenSystem.inst, "Reading Notes Export", "Reading", 1, 1000); int progress = 1; while ((e = zin.getNextEntry()) != null) { unzip(zin, e.getName(), node.getDir()); progress++; if (progress > 99) { progress = 99; } pm.setProgress(progress); } zin.close(); pm.close(); } } catch (IOException e) { JOptionPane.showMessageDialog(this, "Error Reading File" + notesFile.getName()); Logging.errorPrint("Error Reading File" + notesFile.getName()); Logging.errorPrint(e.getMessage(), e); } }
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 *//*w ww .j a v a2s .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
/** * * @param images images to be transformed into a {@link OCRSelectPanelPanel} * or {@code null} indicating that no scan data was persisted when opening a * persisted entry//from w ww . ja v a2 s.com * @param documentFile The {@link File} the document is stored in. * {@code null} indicates that the document has not been saved yet (e.g. if * the {@link OCRSelectComponent} represents scan data). * @throws DocumentAddException */ public void addDocument(final List<BufferedImage> images, final File documentFile, final Object entityToEdit) throws DocumentAddException { if (ADD_DOCUMENT_ASYNC) { final ProgressMonitor progressMonitor = new ProgressMonitor(this, //parent "Generating new document tab", //message null, //note 0, //min 100 //max ); progressMonitor.setMillisToPopup(0); progressMonitor.setMillisToDecideToPopup(0); final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { private OCRSelectComponent createdOCRSelectComponentScrollPane; @Override protected Void doInBackground() throws Exception { try { this.createdOCRSelectComponentScrollPane = addDocumentRoutine(images, documentFile, entityToEdit, progressMonitor); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Override protected void done() { progressMonitor.close(); addDocumentDone(this.createdOCRSelectComponentScrollPane); } }; worker.execute(); progressMonitor.setProgress(1); //ProgressMonitor dialog blocks until SwingWorker.done //is invoked } else { OCRSelectComponent oCRSelectComponentScrollPane = addDocumentRoutine(images, documentFile, entityToEdit, null //progressMonitor ); addDocumentDone(oCRSelectComponentScrollPane); } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void miExportToExcelActionPerformed(ActionEvent e) { if (listsPopupMenu.getInvoker() == vechicleTypesList || listsPopupMenu.getInvoker() == manufactorsList || listsPopupMenu.getInvoker() == seriesList) { ExportWindow exportWindow = new ExportWindow(); exportWindow.setVisible(true);/*from w w w .j a va 2 s . com*/ if (exportWindow.getDialogResult() == DialogResult.OK) { final ProgressMonitor progressMonitor = new ProgressMonitor(this, " ", ", ?? ", 0, 100); progressMonitor.setProgress(0); progressMonitor.setMillisToPopup(0); progressMonitor.setMillisToDecideToPopup(0); FullCatalogExportTask task = new FullCatalogExportTask(exportWindow.getExportParams(), listsPopupMenu.getInvoker()); task.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("progress")) { progressMonitor.setProgress(new Integer(evt.getNewValue().toString())); } } }); task.execute(); } } }
From source file:ru.goodfil.catalog.ui.forms.MainWindow.java
private void miExportOeToExcelActionPerformed(ActionEvent e) { final ProgressMonitor progressMonitor = new ProgressMonitor(this, " ", ", ?? ", 0, 100); progressMonitor.setProgress(10); progressMonitor.setMillisToPopup(0); ExportOeTask task = new ExportOeTask(); task.addPropertyChangeListener(new PropertyChangeListener() { @Override//ww w . j ava 2s .c o m public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("progress")) { Integer progress = new Integer(evt.getNewValue().toString()); progressMonitor.setProgress(progress); } } }); task.execute(); }
From source file:ru.goodfil.catalog.ui.forms.MainWindow.java
private void menuItem1ExportOeCross(ActionEvent e) { final ProgressMonitor progressMonitor = new ProgressMonitor(this, " ", ", ?? ", 0, 100); progressMonitor.setProgress(10); progressMonitor.setMillisToPopup(0); ExportOeTaskCross task = new ExportOeTaskCross(); task.addPropertyChangeListener(new PropertyChangeListener() { @Override// w w w . java 2 s. c o m public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("progress")) { Integer progress = new Integer(evt.getNewValue().toString()); progressMonitor.setProgress(progress); } } }); task.execute(); }