我試圖改變光標當我開始操作。我希望光標顯示忙,直到操作完成。我有一個單獨的類爲operationListener。 我不知道如何分配光標?從AplotBaseDialog類SWT - 顯示忙碌光標
呼叫
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
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);
} // end startPrinterListOperation()
我基本上剛剛添加上述行到我的操作方法,因爲它開始然後就在對話框打開之前,它似乎工作。我真的希望我能想出如何使它在抽象操作類中工作。但是這似乎具有相同的效果。 - 謝謝 – jkteater