Package com.dbxml.util

Examples of com.dbxml.util.Stopwatch


            case 2:
               if ( info instanceof HasDocWrapper ) {
                  e.consume();
                  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                  Stopwatch sw = new Stopwatch("Document Retrieval", true);
                  DocWrapper dw = ((HasDocWrapper)info).getDocWrapper();
                  sw.stop();
                  admin.setStatus(sw.toString());
                  admin.editDocument(dw);
                  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
               }
               break;
         }
View Full Code Here


         }

         pw.println("Exporting " + fileCount + " " + type + "s");

         boolean estimate = fileCount > SAMPLE_SET * 10;
         Stopwatch sw = new Stopwatch("Estimated remaining export time");
         for ( int i = 0; i < fileCount; i++ ) {
            if ( estimate && i == 0 )
               sw.start();
            String fn = (String)files.get(i);
            File f = new File(dir, fn);

            if ( binary )
               exportBin(col, f, fn, estimate);
            else
               exportDoc(col, f, fn, estimate);
            if ( estimate && i > 0 && i % SAMPLE_SET == 0 ) {
               long t = ((fileCount - i) * sw.elapsed()) / i;
               pw.print("\r" + sw.toString(t) + EOL_STRING);
               pw.flush();
            }
         }
         if ( estimate )
            pw.println();
View Full Code Here

         DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
         AdminNode info = (AdminNode)node.getUserObject();

         if ( info instanceof HasDocWrapper ) {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            Stopwatch sw = new Stopwatch("Document Retrieval", true);
            DocWrapper dw = ((HasDocWrapper)info).getDocWrapper();
            sw.stop();
            statusBar.setText(sw.toString());
            editDocument(dw);
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         }
      }
      catch ( Exception ex ) {
View Full Code Here

      if ( name != null && name.length() > 0 )
         doc.setName(name);
      else
         return false;

      Stopwatch sw = new Stopwatch("Document Storage", true);
      TabbedNodeEditor ne = (TabbedNodeEditor)paneEdit.getSelectedComponent();
      if ( ne.deactivate() ) {
         store.storeDocWrapper(doc);
         ne.activate(readOnly);
         nodeEditor = ne;
      }
      sw.stop();
      statusBar.setText(sw.toString());

      DefaultMutableTreeNode refreshNode = null;
      if ( nodes[nodes.length-1] == refresh )
         refreshNode = (DefaultMutableTreeNode)components[nodes.length-1];
      else {
View Full Code Here

      newDocument = false;
      return true;
   }

   private boolean storeExistingDocument() {
      Stopwatch sw = new Stopwatch("Document Storage", true);
      TabbedNodeEditor ne = (TabbedNodeEditor)paneEdit.getSelectedComponent();
      if ( ne.deactivate() ) {
         doc.store();
         ne.activate(readOnly);
         nodeEditor = ne;
      }
      sw.stop();
      statusBar.setText(sw.toString());
      return true;
   }
View Full Code Here

         AdminNode info = (AdminNode)node.getUserObject();

         if ( info instanceof HasCollection && ((HasCollection)info).getCollection() != null ) {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            CollectionClient col = ((HasCollection)info).getCollection();
            Stopwatch sw = new Stopwatch("Query Results", true);
            String style;
            switch ( cmbQueryType.getSelectedIndex() ) {
               case 0:  style = XPathQueryResolver.STYLE_XPATH;       break;
               case 1:  style = FullTextQueryResolver.STYLE_FULLTEXT; break;
               case 2:  style = XSLTQueryResolver.STYLE_XSLT;         break;
               default: style = XUpdateQueryResolver.STYLE_XUPDATE;   break;
            }
            ResultSetClient rs = col.queryCollection(style, query, cfg.getNamespaceMap());

            sw.stop();
            statusBar.setText(sw.toString());

            Document doc = DOMHelper.newDocument();
            Element root = doc.createElementNS(Query.NSURI, Query.PREFIX+":"+ResultSetWrapper.RESULTS);
            String colName = rs.getCollection().getCanonicalName();
            root.setAttribute("xmlns:"+Query.PREFIX, Query.NSURI);
View Full Code Here

         pw.println("Importing " + fileCount + " " + type + "s");

         boolean estimate = fileCount > SAMPLE_SET * 10;
         pw.println("Average " + type + " size is " + (size / fileCount) + " bytes");
         Stopwatch sw = new Stopwatch("Estimated remaining load time");
         for ( int i = 0; i < fileCount; i++ ) {
            if ( estimate && i == 0 )
               sw.start();
            File f = (File)files.get(i);
            if ( binary )
               importBin(col, f, f.getName(), estimate);
            else
               importDoc(col, f, f.getName(), estimate);

            if ( estimate && i > 0 && i % SAMPLE_SET == 0 ) {
               long t = ((fileCount - i) * sw.elapsed()) / i;
               pw.print("\r" + sw.toString(t) + EOL_STRING);
               pw.flush();
            }
         }
         if ( estimate )
            pw.println();
View Full Code Here

                  String verb = getNextToken().toUpperCase();
                  CommandInfo info = (CommandInfo)commands.get(verb);
                  if ( info != null ) {
                     if ( isPropertyTrue(INTERACTIVE) )
                        out.println();
                     Stopwatch sw = new Stopwatch("Execution", true);
                     info.command.process();
                     sw.stop();
                     if ( isPropertyTrue(DURATIONS) )
                        out.println("(" + sw.toString() + ")");
                     if ( isPropertyTrue(INTERACTIVE) )
                        out.println();
                  }
                  else
                     unknownVerb(verb);
View Full Code Here

            }
            break;

         case ACTION_EDIT:
            admin.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            Stopwatch sw = new Stopwatch("Document Retrieval", true);
            DocWrapper dw = getDocWrapper();
            sw.stop();
            admin.setStatus(sw.toString());
            admin.editDocument(dw);
            admin.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            break;

         case ACTION_XSLT:
View Full Code Here

               fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
               fc.setMultiSelectionEnabled(true);
               int result = fc.showDialog(admin, "Import");
               if ( result == JFileChooser.APPROVE_OPTION ) {
                  admin.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                  Stopwatch sw = new Stopwatch(true);
                  boolean docs = col.getCollectionType() == CollectionClient.TYPE_DOCUMENTS;
                  int count = 0;
                  int error = 0;
                  File[] files = fc.getSelectedFiles();
                  for ( int i = 0; i < files.length; i++ ) {
                     File file = files[i];
                     String docName = file.getName();
                     try {
                        if ( docs )
                           importDoc(docName, file);
                        else
                           importBin(docName, file);
                        count++;
                     }
                     catch ( Exception e ) {
                        error++;
                        admin.addMessage("Couldn't import '" + docName + "': "+e.getMessage());
                     }
                  }
                  sw.stop();
                  if ( error > 0 )
                     admin.addMessage(count+" Document(s) imported ("+error+" errors): "+sw.toString());
                  else
                     admin.setStatus(count+" Document(s) imported: "+sw.toString());
                  admin.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
               }
               return REFRESH_CHILDREN;
            }
            catch ( dbXMLException e ) {
View Full Code Here

TOP

Related Classes of com.dbxml.util.Stopwatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.