Skip to content

Commit a060613

Browse files
committed
new preference example
1 parent 726182d commit a060613

26 files changed

Lines changed: 384 additions & 19 deletions

File tree

‎de.vogella.jobs.first/plugin.xml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
</extension>
2222
<extension
2323
point="org.eclipse.ui.commands">
24+
<command
25+
defaultHandler="de.vogella.jobs.first.handler.RunUiJob1"
26+
id="de.vogella.jobs.first.runUiJob"
27+
name="Run Ui Job">
28+
</command>
2429
<command
2530
defaultHandler="de.vogella.jobs.first.handler.RunJob1"
2631
id="de.vogella.jobs.first.runJob1"
@@ -36,6 +41,11 @@
3641
label="Start Job"
3742
style="push">
3843
</command>
44+
<command
45+
commandId="de.vogella.jobs.first.runUiJob"
46+
label="Ui Job"
47+
style="push">
48+
</command>
3949
</menuContribution>
4050
</extension>
4151

‎de.vogella.jobs.first/src/de/vogella/jobs/first/ApplicationWorkbenchWindowAdvisor.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ public void preWindowOpen() {
2222
configurer.setShowCoolBar(false);
2323
configurer.setShowStatusLine(false);
2424
configurer.setTitle("Hello RCP");
25+
configurer.setShowProgressIndicator(true);
2526
}
2627
}

‎de.vogella.jobs.first/src/de/vogella/jobs/first/handler/RunJob1.java‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package de.vogella.jobs.first.handler;
22

3-
43
import org.eclipse.core.commands.AbstractHandler;
54
import org.eclipse.core.commands.ExecutionEvent;
65
import org.eclipse.core.commands.ExecutionException;
@@ -9,37 +8,37 @@
98
import org.eclipse.core.runtime.Status;
109
import org.eclipse.core.runtime.jobs.Job;
1110
import org.eclipse.jface.dialogs.MessageDialog;
11+
import org.eclipse.swt.widgets.Display;
1212
import org.eclipse.ui.handlers.HandlerUtil;
1313

1414
public class RunJob1 extends AbstractHandler {
1515

1616
@Override
1717
public Object execute(final ExecutionEvent event) throws ExecutionException {
18-
Job job = new Job("First Job"){
18+
Job job = new Job("First Job") {
1919
@Override
2020
protected IStatus run(IProgressMonitor monitor) {
21-
22-
for (int i=0; i<10; i++){
21+
for (int i = 0; i < 10; i++) {
2322
try {
24-
Thread.sleep(100);
23+
// We simulate a long running operation here
24+
Thread.sleep(1000);
2525
} catch (InterruptedException e) {
2626
e.printStackTrace();
2727
}
2828
System.out.println("Doing something");
2929
}
30-
HandlerUtil.getActiveShell(event).getDisplay().getDefault().asyncExec(new Runnable() {
31-
public void run() {
32-
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Info", "Info for you");
33-
}
30+
// Use this to open a Shell in the UI thread
31+
Display.getDefault().asyncExec(new Runnable() {
32+
public void run() {
33+
MessageDialog.openInformation(
34+
HandlerUtil.getActiveShell(event),
35+
"Your Popup ", "Your job has finished.");
36+
}
3437
});
35-
36-
37-
38-
3938
return Status.OK_STATUS;
4039
}
41-
42-
};
40+
41+
};
4342
job.setUser(true);
4443
job.schedule();
4544
return null;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package de.vogella.jobs.first.handler;
2+
3+
import org.eclipse.core.commands.AbstractHandler;
4+
import org.eclipse.core.commands.ExecutionEvent;
5+
import org.eclipse.core.commands.ExecutionException;
6+
import org.eclipse.core.runtime.IProgressMonitor;
7+
import org.eclipse.core.runtime.IStatus;
8+
import org.eclipse.core.runtime.Status;
9+
import org.eclipse.jface.dialogs.MessageDialog;
10+
import org.eclipse.ui.handlers.HandlerUtil;
11+
import org.eclipse.ui.progress.UIJob;
12+
13+
public class RunUiJob1 extends AbstractHandler {
14+
15+
@Override
16+
public Object execute(final ExecutionEvent event) throws ExecutionException {
17+
UIJob job = new UIJob("First Job") {
18+
@Override
19+
public IStatus runInUIThread(IProgressMonitor monitor) {
20+
for (int i = 0; i < 10; i++) {
21+
try {
22+
// We simulate a long running operation here
23+
Thread.sleep(1000);
24+
} catch (InterruptedException e) {
25+
e.printStackTrace();
26+
}
27+
System.out.println("Doing something");
28+
}
29+
MessageDialog.openInformation(
30+
HandlerUtil.getActiveShell(event), "Your Popup ",
31+
"Your job has finished.");
32+
33+
return Status.OK_STATUS;
34+
}
35+
36+
};
37+
job.setUser(true);
38+
job.schedule();
39+
return null;
40+
}
41+
42+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>de.vogella.preferences.access</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.pde.PluginNature</nature>
26+
<nature>org.eclipse.jdt.core.javanature</nature>
27+
</natures>
28+
</projectDescription>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Fri Sep 17 20:58:10 CEST 2010
2+
eclipse.preferences.version=1
3+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5+
org.eclipse.jdt.core.compiler.compliance=1.6
6+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8+
org.eclipse.jdt.core.compiler.source=1.6
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: Access
4+
Bundle-SymbolicName: de.vogella.preferences.access; singleton:=true
5+
Bundle-Version: 1.0.0.qualifier
6+
Bundle-Activator: de.vogella.preferences.access.Activator
7+
Require-Bundle: org.eclipse.ui,
8+
org.eclipse.core.runtime
9+
Bundle-ActivationPolicy: lazy
10+
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source.. = src/
2+
output.. = bin/
3+
bin.includes = plugin.xml,\
4+
META-INF/,\
5+
.,\
6+
icons/
983 Bytes
Loading

0 commit comments

Comments
 (0)