Home > Domino Tips > Developer > Domino > Dynamic mail file size & quota indicator applet
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DOMINO

Dynamic mail file size & quota indicator applet


Dhana Sekar
08.05.2002
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


The applet explained below best describes one of the many advantages , and in fact only way(not using agents etc), of java in Lotus Domino.

About the Applet : It displays a progress bar with the current mail file size & quota (if set), and % used.(updated every 10000 Millisecs). Thus giving the user an indication about their mail file usage.

Logic : The applet starts a Thread as soon as it loads and establishes a session with domino. The Thread runs in a infinite loop .ie.,thread sleeps for 10000 millisecs and then fetches the db size, quota and calculates % used. If their is a change in these parameters, the repaint() method of the applet is called to update the progress bar.

How to use : Compile the program (with the right classpath set), create an applet resource. Insert the applet in a form. Set its height ,width to 100 pixels and 30 pixels resp. Create a field near to the applet and find your mail quota and set to this field using postopen method. Ensure Enable java applets is selected in the user preferences.

Applicability : We have customized the welcome page for our organisation and my applet has taken up a corner of it(occupies very little space). So it can be used in the welcome page, mail frameset ,portals etc.

Restriction: Works fine in client. It can be further modified to work on web also (CORBA).



Code

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Font;
import lotus.domino.Session;
import lotus.domino.DbDirectory;
import lotus.domino.Database;
import lotus.domino.AppletBase;
import lotus.domino.NotesThread;

public class Simple extends AppletBase implements Runnable

{

private Session session=null;
private DbDirectory dbDir=null; 
private Database mailDb=null;
private double quota=0.0,prevQuota=0.0;
private double fileSize=0.0,prevFileSize=0.0;
private Thread listener=null;
private int usedVal=0; 
public void notesAppletInit()
{
try
{
NotesThread.sinitThread(); 

session = this.getSession();
dbDir = session.getDbDirectory(null);
mailDb = dbDir.openMailDatabase();
setBackground(new Color(239,239,239));

if(mailDb!=null)
{
quota = mailDb.getSizeQuota();

if(quota<=0)
{ 
repaint();
} 
else 
{ 
listener = new Thread(this);
listener.start();
}
}
}
catch(Exception e)
{
System.out.println("Notes Applet Start Exception " + e);
}
finally
{
NotesThread.stermThread(); 
}
}

public void run()
{
try
{
NotesThread.sinitThread();

while(true) 
{
if(mailDb!=null) 
{
quota = mailDb.getSizeQuota();
fileSize = mailDb.getSize();
} 

if(quota!=0.0 && fileSize!=0.0)
{
quota = quota/1024;
fileSize = fileSize/(1024*1024);
usedVal = (int) Math.floor((fileSize/quota)*100);

if(quota!=prevQuota || fileSize!=prevFileSize)
{
prevQuota = quota;
prevFileSize = fileSize; 
repaint();
}

listener.sleep(10000);
}
}
}
catch(Exception e)
{ 
System.out.println("Run Exception " + e);
} 
finally
{
listener=null;
NotesThread.stermThread();
}
}

public void paint(Graphics g)
{
try
{
NotesThread.sinitThread(); 

if(quota<=0)
{
g.drawString("Mail quota is not set",1,15); 
}
else
{
g.setColor(new Color(11,148,212));
g.fill3DRect(0,0,usedVal,30,true);
g.setColor(Color.black);
g.setFont(new Font("Arial",Font.PLAIN,9));

if(usedVal<=15)
{
g.drawString(Math.ceil(fileSize)+" mb",10,12);
g.drawString(usedVal +" %",10,28);
}
else if(usedVal>=85)
{
g.drawString(usedVal +" %",75,28);
g.drawString(Math.ceil(fileSize)+" mb",60,12);
}
else
{
g.drawString(usedVal +" %",usedVal-12,28);
g.drawString(Math.ceil(fileSize)+" mb",usedVal-12,12);
} 
}
}
catch(Exception e)
{
System.out.println("Paint Exception " + e);
}
finally
{
NotesThread.stermThread();
}
}

public void notesAppletDestroy()
{
try
{
session = null;
dbDir = null;
mailDb = null;
}
catch(Exception e)
{
System.out.println("Destroy Exception " + e);
} 
} 
}

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Domino
Mimic Lotus Notes Domino application functionality on the Web
A single form to view and edit any Lotus Notes document
DECS and DCR external data access considerations
How to create non-scrolling Lotus Domino view headers on the Web
Disabling the 'Submit' button on a form
An easier way to update a rich text field
Results from Default Notes Search have # of responses in brackets
Lotus Notes/Domino veteran offers comprehensive list of app dev tools
Notes to XML. . .and back again
Creating thumbnail images using LS2J in LotusScript

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts