Sto provando a cambiare il cursore quando avvio un'operazione. Voglio che il cursore mostri occupato fino al termine dell'operazione. Ho una classe separata per OperationListener. Non sono sicuro di come assegnare il cursore?SWT - Mostra un cursore occupato
chiamata dalla classe AplotBaseDialog
listOp.addOperationListener(new MyOperationListener(this) {
etc....
}
classe separata
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()
Fondamentalmente ho aggiunto le linee precedenti al mio metodo operativo come è iniziato subito prima che la finestra di dialogo fosse aperta e sembra funzionare. Vorrei davvero aver capito come farlo funzionare nella classe di operazioni astratte. Ma questo sembra avere lo stesso effetto. - Grazie – jkteater