I am developing a rcp application .I am using a Novocode swt balloon window . I need to display one BaloonWindow on button click.but whenever I click on button each time create a new balloon window
My code is below
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
BalloonWindow baloonWindow=new BalloonWindow(HandlerUtil.getActiveWorkbenchWindow(event).getShell(),SWT.ON_TOP|SWT.TOOL|SWT.CLOSE);
baloonWindow.setText("XYZ");
baloonWindow.setAnchor(SWT.RIGHT|SWT.TOP);
baloonWindow.setLocation(1290, 90);
Composite c = baloonWindow.getContents();
String array[]=new String[2];
array[0]="A";
array[1]="B";
c.setLayout(new FillLayout());
TableViewer t=new TableViewer(c,SWT.NONE);
t.setContentProvider(new ArrayContentProvider());
t.setInput(array);
c.pack(true);
baloonWindow.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
anybody can help me.how to show only one balloon window at time.if a balloon window is open then another balloon window should not be allowed to open or there should remain only one balloon window open at any given point of time.
I'm not quite sure I understood you ultimate goal, so here are two possibilities:
First (at most one
BalloonWindowat a time)Create a
staticbooleanfieldisOpenin your class containing theexecute()method. Set this variable totrueonce you created theBalloonWindowand check this variable each time you enterexecute(). If it isfalse, create a newBalloonWindow, if it istrue,return.Second (close the
BalloonWindow)The
BalloonWindowhas a methodopen(). Use this method to open it instead ofsetVisible(true). If you want to close theBalloonWindow, just callclose().setVisible(false)would have the same visual effect (the window is gone), but it would still be there (only invisible).closereally closes the window.