我试图在开始操作时更改光标。我希望光标显示忙碌,直到操作完成。我有一个单独的 operationListener 类。我不确定如何分配光标?
从 AplotBaseDialog 类调用
listOp.addOperationListener(new MyOperationListener(this) {
etc....
}
单独的班级
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;
} // end constructor
public void startOperation(String startMessage) {
** should this be getting a Shell form the AplotBaseDialog? **
w.???.setCursor(busyCursor);
} // end startOperation()
public void endOperation() {
try {
endOperationImpl();
}
finally {
w.???.setCursor(null);
}
} // end endOperation()
abstract protected void endOperationImpl();
} // end class MyOperationListener
编辑
plotButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(Display.getDefault(), new Runnable(){
public void run(){
startPrinterListOperation();
}
});
}
});
编辑
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);
} // end startPrinterListOperation()