logo

Adding a Progress Bar to Notes Agent

On Tuesday I showed a custom "Java Console" I'd thrown together. Today I'm going to extend it by adding a progress bar.

Here's what it looks like in use:

image

And when done:

image

Here's the code for using it:

public class JavaAgent extends AgentBase {

 private OutputWindowWithProgressBar progressWindow = new OutputWindowWithProgressBar();

 public void NotesMain() {

  try {
   Session session = getSession();
   AgentContext agentContext = session.getAgentContext();

   DocumentCollection docs = agentContext.getUnprocessedDocuments();
   Document doc = docs.getFirstDocument();

   progressWindow.setTitle("Updating Selecting Documents");
   progressWindow.setProgressBarMax(docs.getCount());
   progressWindow.show();

   int i = 1;

   while (doc!=null){
      progressWindow.println(
         "Processing document " + doc.getUniversalID());
      progressWindow.setProgress(i);

      doc = docs.getNextDocument(doc);
      i++;
   }

   progressWindow.println("Done");

  } catch(Exception e) {
   e.printStackTrace();
  } finally {
   progressWindow.setCloseable(true);
  }
 }
}

The OutputWindowWithProgressBar class extends the OutputWindow class I shared on Tuesday. The code for the new progress bar window is here. You'll need to make the JFrame object in the OutputWindow class protected instead of private for it all to work. Like so:

protected static JFrame frame;

Hope you like.

Comments

  1. Very nice! I blogged about a Lotusscript progress bar a while back, but that is just the progress bra, not with the text/details:

    http://www.bleedyellow.com/blogs/texasswede/entry/progressbar_class_for_lotusscript1?lang=en

  2. Very nice!

    But what happens, if you start that agent on the server?

      • avatar
      • Jake Howlett
      • Fri 30 Mar 2012 11:40 AM

      Hmm. Not sure. I'd guess it would throw a classnotfound exception as the Swing classes aren't a part of the server? Dunno.

  3. The Java Swing classes are included with the runtime jar in the Notes JRE going back to at least Domino 6, on both the server and the client. So you wouldn't get a ClassNotFound.

    However, you might get a security manager error.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Fri 30 Mar 2012

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content