|
Lines 11-16
Link Here
|
| 11 |
|
11 |
|
| 12 |
package org.eclipse.rap.demo.wizard; |
12 |
package org.eclipse.rap.demo.wizard; |
| 13 |
|
13 |
|
|
|
14 |
import java.lang.reflect.InvocationTargetException; |
| 15 |
|
| 16 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 17 |
import org.eclipse.jface.dialogs.Dialog; |
| 18 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 19 |
import org.eclipse.jface.operation.IRunnableContext; |
| 20 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
| 14 |
import org.eclipse.jface.wizard.IWizardPage; |
21 |
import org.eclipse.jface.wizard.IWizardPage; |
| 15 |
import org.eclipse.jface.wizard.WizardPage; |
22 |
import org.eclipse.jface.wizard.WizardPage; |
| 16 |
import org.eclipse.swt.SWT; |
23 |
import org.eclipse.swt.SWT; |
|
Lines 60-65
Link Here
|
| 60 |
setErrorMessage( null ); |
67 |
setErrorMessage( null ); |
| 61 |
} |
68 |
} |
| 62 |
} ); |
69 |
} ); |
|
|
70 |
Button runButton = new Button(composite, SWT.PUSH); |
| 71 |
runButton.setText( "Run button" ); |
| 72 |
final Shell shell = getShell(); |
| 73 |
final IRunnableContext context = getWizard().getContainer(); |
| 74 |
runButton.addSelectionListener( new SelectionAdapter() { |
| 75 |
|
| 76 |
public void widgetSelected( SelectionEvent e ) { |
| 77 |
IRunnableWithProgress runnable = new IRunnableWithProgress() |
| 78 |
{ |
| 79 |
|
| 80 |
public void run( IProgressMonitor monitor ) |
| 81 |
throws InvocationTargetException, InterruptedException |
| 82 |
{ |
| 83 |
monitor.worked(50); |
| 84 |
shell.getDisplay().syncExec( new Runnable() { |
| 85 |
|
| 86 |
public void run() { |
| 87 |
Dialog dlg = new ProgressDialog(shell); |
| 88 |
dlg.setBlockOnOpen( false ); |
| 89 |
dlg.open(); |
| 90 |
} |
| 91 |
}); |
| 92 |
for (int i = 1; i <= 5; i++) |
| 93 |
{ |
| 94 |
monitor.worked( 10*i ); |
| 95 |
Thread.sleep( 500 ); |
| 96 |
} |
| 97 |
monitor.done(); |
| 98 |
} |
| 99 |
}; |
| 100 |
try { |
| 101 |
context.run( true, false, runnable ); |
| 102 |
} |
| 103 |
catch( InvocationTargetException ignored ) { |
| 104 |
} |
| 105 |
catch( InterruptedException ignored ) { |
| 106 |
} |
| 107 |
MessageDialog.openInformation(getShell(), "Title", "Done!"); |
| 108 |
} |
| 109 |
|
| 110 |
}); |
| 63 |
setControl( composite ); |
111 |
setControl( composite ); |
| 64 |
} |
112 |
} |
| 65 |
|
113 |
|
|
Lines 79-82
Link Here
|
| 79 |
setErrorMessage( "You need to select at least one entry" ); |
127 |
setErrorMessage( "You need to select at least one entry" ); |
| 80 |
return false; |
128 |
return false; |
| 81 |
} |
129 |
} |
|
|
130 |
|
| 131 |
class ProgressDialog |
| 132 |
extends Dialog |
| 133 |
{ |
| 134 |
|
| 135 |
protected ProgressDialog( Shell parentShell ) { |
| 136 |
super( parentShell ); |
| 137 |
setShellStyle((getShellStyle() | SWT.APPLICATION_MODAL) & ~SWT.CLOSE); |
| 138 |
} |
| 139 |
|
| 140 |
} |
| 82 |
} |
141 |
} |