I am trying to change the cursor when starting an operation. I want the cursor to show busy until the operation is completed. I have a separate class for operatorListener. I'm not sure how to assign a cursor?
A call from the AplotBaseDialog class
listOp.addOperationListener(new MyOperationListener(this) {
etc....
}
Separate class
public abstract class MyOperationListener implements InterfaceAIFOperationListener {
Cursor busyCursor = null;
AplotBaseDialog w = null;
public MyOperationListener(AplotBaseDialog win) {
**Should this not be getCurrent?**
busyCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
w = win;
}
public void startOperation(String startMessage) {
** should this be getting a Shell form the AplotBaseDialog? **
w.???.setCursor(busyCursor);
}
public void endOperation() {
try {
endOperationImpl();
}
finally {
w.???.setCursor(null);
}
}
abstract protected void endOperationImpl();
}
EDIT
plotButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(Display.getDefault(), new Runnable(){
public void run(){
startPrinterListOperation();
}
});
}
});
EDIT
private void startPrinterListOperation() {
listOp = new AplotPrinterListOperation(appReg.getString("aplot.message.GETPRINTERLIST"), session);
listOp.addOperationListener(new MyOperationListener(this) {
public void endOperationImpl() {
try {
printers.clear();
printers.addAll((ArrayList<PrinterProfile>) listOp.getPrinters());
Display.getDefault().asyncExec(new Runnable() {
public void run() {
showAplotPlotterDialog();
}
});
}
finally {
listOp.removeOperationListener(this);
listOp = null;
}
}
});
session.queueOperation(listOp);
}
source
share