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:
And when done:
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.
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
Reply
Very nice!
But what happens, if you start that agent on the server?
Reply
Hmm. Not sure. I'd guess it would throw a classnotfound exception as the Swing classes aren't a part of the server? Dunno.
Reply
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.
Reply