Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper Eskilson2016-03-29 03:19:35 -0400
committerGerrit Code Review @ Eclipse.org2016-03-29 16:18:03 -0400
commit92cd62689549bb20b1eeafac659c9276aac1b940 (patch)
treefdf3bc1b79c4e1d178421f86e28810906391e1dc
parenta08b9582d349e66f9922780c1bc9a51feb59cb5e (diff)
downloadorg.eclipse.cdt-92cd62689549bb20b1eeafac659c9276aac1b940.tar.gz
org.eclipse.cdt-92cd62689549bb20b1eeafac659c9276aac1b940.tar.xz
org.eclipse.cdt-92cd62689549bb20b1eeafac659c9276aac1b940.zip
Code cleanup in DSF examples.
- Added @Override where necessary. - Added src_ant to source directories in build.properties - Fixed resource leaks - Added type parameters where missing (e.g. Vector in PreProcessor.java) - Removed unused imports Change-Id: I28c7e295891833f9b561975da0adc92d55f2e048 Signed-off-by: Jesper Eskilson <jesper.eskilson@iar.com>
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda/pdavm/src/org/eclipse/cdt/examples/pdavm/PDAVirtualMachine.java53
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/META-INF/MANIFEST.MF2
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/build.properties3
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/pom.xml2
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_ant/org/eclipse/cdt/examples/ant/tasks/PreProcessor.java14
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataGenerator.java39
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataViewer.java21
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncDataViewer.java21
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataGenerator.java21
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataViewer.java15
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorCacheManager.java6
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java42
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java17
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/SyncDataViewer.java18
14 files changed, 170 insertions, 104 deletions
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda/pdavm/src/org/eclipse/cdt/examples/pdavm/PDAVirtualMachine.java b/dsf/org.eclipse.cdt.examples.dsf.pda/pdavm/src/org/eclipse/cdt/examples/pdavm/PDAVirtualMachine.java
index 875d01bb94..92ff115a38 100644
--- a/dsf/org.eclipse.cdt.examples.dsf.pda/pdavm/src/org/eclipse/cdt/examples/pdavm/PDAVirtualMachine.java
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda/pdavm/src/org/eclipse/cdt/examples/pdavm/PDAVirtualMachine.java
@@ -420,32 +420,33 @@ public class PDAVirtualMachine {
pdaVM.run();
}
- PDAVirtualMachine(String inputFile, boolean debug, int commandPort, int eventPort) throws IOException {
- fFilename = inputFile;
-
- // Load all the code into memory
- FileReader fileReader = new FileReader(inputFile);
- StringWriter stringWriter = new StringWriter();
- List<String> code = new LinkedList<String>();
- int c = fileReader.read();
- while (c != -1) {
- if (c == '\n') {
- code.add(stringWriter.toString().trim());
- stringWriter = new StringWriter();
- } else {
- stringWriter.write(c);
- }
- c = fileReader.read();
- }
- code.add(stringWriter.toString().trim());
- fCode = code.toArray(new String[code.size()]);
-
- fLabels = mapLabels(fCode);
-
- fDebug = debug;
- fCommandPort = commandPort;
- fEventPort = eventPort;
- }
+ PDAVirtualMachine(String inputFile, boolean debug, int commandPort, int eventPort) throws IOException {
+ fFilename = inputFile;
+
+ // Load all the code into memory
+ try (FileReader fileReader = new FileReader(inputFile)) {
+ StringWriter stringWriter = new StringWriter();
+ List<String> code = new LinkedList<String>();
+ int c = fileReader.read();
+ while (c != -1) {
+ if (c == '\n') {
+ code.add(stringWriter.toString().trim());
+ stringWriter = new StringWriter();
+ } else {
+ stringWriter.write(c);
+ }
+ c = fileReader.read();
+ }
+ code.add(stringWriter.toString().trim());
+ fCode = code.toArray(new String[code.size()]);
+
+ fLabels = mapLabels(fCode);
+
+ fDebug = debug;
+ fCommandPort = commandPort;
+ fEventPort = eventPort;
+ }
+ }
/**
* Initializes the labels map
diff --git a/dsf/org.eclipse.cdt.examples.dsf/META-INF/MANIFEST.MF b/dsf/org.eclipse.cdt.examples.dsf/META-INF/MANIFEST.MF
index 02c2eaadb1..ceb10d801e 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/META-INF/MANIFEST.MF
+++ b/dsf/org.eclipse.cdt.examples.dsf/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.examples.dsf;singleton:=true
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 2.2.0.qualifier
Bundle-Activator: org.eclipse.cdt.examples.dsf.DsfExamplesPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
diff --git a/dsf/org.eclipse.cdt.examples.dsf/build.properties b/dsf/org.eclipse.cdt.examples.dsf/build.properties
index c34b077e9c..bf96f406c6 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/build.properties
+++ b/dsf/org.eclipse.cdt.examples.dsf/build.properties
@@ -8,7 +8,8 @@
# Contributors:
# Wind River Systems - initial API and implementation
###############################################################################
-source.. = src/
+source.. = src/,\
+ src_ant/
output.. = bin/
bin.includes = META-INF/,\
.,\
diff --git a/dsf/org.eclipse.cdt.examples.dsf/pom.xml b/dsf/org.eclipse.cdt.examples.dsf/pom.xml
index 12c28f02c0..59f93840a6 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/pom.xml
+++ b/dsf/org.eclipse.cdt.examples.dsf/pom.xml
@@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>2.1.0-SNAPSHOT</version>
+ <version>2.2.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.examples.dsf</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_ant/org/eclipse/cdt/examples/ant/tasks/PreProcessor.java b/dsf/org.eclipse.cdt.examples.dsf/src_ant/org/eclipse/cdt/examples/ant/tasks/PreProcessor.java
index f8f28808e8..0b2f78e152 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_ant/org/eclipse/cdt/examples/ant/tasks/PreProcessor.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_ant/org/eclipse/cdt/examples/ant/tasks/PreProcessor.java
@@ -47,9 +47,9 @@ import org.apache.tools.ant.util.FileUtils;
*/
public class PreProcessor extends Task {
- private Vector fFileSets = new Vector();
+ private Vector<FileSet> fFileSets = new Vector<>();
private File fDestDir = null;
- private Set fSymbols = new HashSet();
+ private Set<String> fSymbols = new HashSet<>();
private FileUtils fUtils = FileUtils.getFileUtils();
// possible states
@@ -116,7 +116,7 @@ public class PreProcessor extends Task {
throw new BuildException("destdir does not exist: " + fDestDir.getAbsolutePath());
}
StringBuffer buf = new StringBuffer("Symbols: ");
- String[] symbols = (String[]) fSymbols.toArray(new String[fSymbols.size()]);
+ String[] symbols = fSymbols.toArray(new String[fSymbols.size()]);
for (int i = 0; i < symbols.length; i++) {
String symbol = symbols[i];
buf.append(symbol);
@@ -126,9 +126,9 @@ public class PreProcessor extends Task {
}
log(buf.toString());
- Iterator fileSets = fFileSets.iterator();
+ Iterator<FileSet> fileSets = fFileSets.iterator();
while (fileSets.hasNext()) {
- FileSet fileSet = (FileSet) fileSets.next();
+ FileSet fileSet = fileSets.next();
DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject());
String[] includedFiles = scanner.getIncludedFiles();
File baseDir = fileSet.getDir(getProject());
@@ -188,9 +188,7 @@ public class PreProcessor extends Task {
* @return
*/
public String preProcessFile(File srcFile, String strip) {
- try {
- FileReader fileReader = new FileReader(srcFile);
- BufferedReader reader = new BufferedReader(fileReader);
+ try (BufferedReader reader = new BufferedReader(new FileReader(srcFile))) {
StringBuffer buffer = new StringBuffer();
String line = reader.readLine();
String activeSymbol = null;
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataGenerator.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataGenerator.java
index 889d59475d..311aec9195 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataGenerator.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataGenerator.java
@@ -80,11 +80,13 @@ public class ACPMSumDataGenerator
}
}
- public void getCount(final DataRequestMonitor<Integer> rm) {
+ @Override
+ public void getCount(final DataRequestMonitor<Integer> rm) {
// Artificially delay the retrieval of the sum data to simulate
// real processing time.
fExecutor.schedule( new Runnable() {
- public void run() {
+ @Override
+ public void run() {
// Create the transaction here to put all the ugly
// code in one place.
new Transaction<Integer>() {
@@ -129,11 +131,13 @@ public class ACPMSumDataGenerator
return maxCount;
}
- public void getValue(final int index, final DataRequestMonitor<Integer> rm)
+ @Override
+ public void getValue(final int index, final DataRequestMonitor<Integer> rm)
{
// Add a processing delay.
fExecutor.schedule( new Runnable() {
- public void run() {
+ @Override
+ public void run() {
new Transaction<Integer>() {
@Override
protected Integer process()
@@ -175,7 +179,8 @@ public class ACPMSumDataGenerator
return sum;
}
- public void shutdown(final RequestMonitor rm) {
+ @Override
+ public void shutdown(final RequestMonitor rm) {
for (DataGeneratorCacheManager dataGeneratorCM : fDataGeneratorCMs) {
dataGeneratorCM.getDataGenerator().removeListener(this);
dataGeneratorCM.dispose();
@@ -184,33 +189,39 @@ public class ACPMSumDataGenerator
rm.done();
}
- public void addListener(final Listener listener) {
+ @Override
+ public void addListener(final Listener listener) {
// Must access fListeners on executor thread.
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
fListeners.add(listener);
}
});
} catch (RejectedExecutionException e) {}
}
- public void removeListener(final Listener listener) {
+ @Override
+ public void removeListener(final Listener listener) {
// Must access fListeners on executor thread.
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
fListeners.remove(listener);
}
});
} catch (RejectedExecutionException e) {}
}
- public void countChanged() {
+ @Override
+ public void countChanged() {
// Must access fListeners on executor thread.
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
for (Listener listener : fListeners) {
listener.countChanged();
}
@@ -219,11 +230,13 @@ public class ACPMSumDataGenerator
} catch (RejectedExecutionException e) {}
}
- public void valuesChanged(final Set<Integer> changed) {
+ @Override
+ public void valuesChanged(final Set<Integer> changed) {
// Must access fListeners on executor thread.
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
for (Object listener : fListeners) {
((Listener)listener).valuesChanged(changed);
}
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataViewer.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataViewer.java
index fd526e74f7..053bae053d 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataViewer.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/ACPMSumDataViewer.java
@@ -107,14 +107,16 @@ public class ACPMSumDataViewer implements ILazyContentProvider
// Schedule a task to refresh the viewer periodically.
fRefreshFuture = fDisplayExecutor.scheduleAtFixedRate(
new Runnable() {
- public void run() {
+ @Override
+ public void run() {
queryItemCount();
}
},
UPDATE_INTERVAL, UPDATE_INTERVAL, TimeUnit.MILLISECONDS);
}
- public void dispose() {
+ @Override
+ public void dispose() {
// Cancel the periodic task of refreshing the view.
fRefreshFuture.cancel(false);
@@ -147,12 +149,14 @@ public class ACPMSumDataViewer implements ILazyContentProvider
fItemDataRequestMonitors.clear();
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Set the initial count to the viewer after the input is set.
queryItemCount();
}
- public void updateElement(final int index) {
+ @Override
+ public void updateElement(final int index) {
// Calculate the visible index range.
final int topIdx = fViewer.getTable().getTopIndex();
final int botIdx = topIdx + getVisibleItemCount(topIdx);
@@ -164,7 +168,8 @@ public class ACPMSumDataViewer implements ILazyContentProvider
// calls to be combined together improving performance of the viewer.
fCancelCallsPending++;
fDisplayExecutor.execute(
- new Runnable() { public void run() {
+ new Runnable() { @Override
+ public void run() {
cancelStaleRequests(topIdx, botIdx);
}});
}
@@ -205,7 +210,8 @@ public class ACPMSumDataViewer implements ILazyContentProvider
// if the cache is reset during processing by an event. The request
// for data will be re-issued.
fDataExecutor.execute(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
new Transaction<Integer>() {
@Override
protected Integer process()
@@ -274,7 +280,8 @@ public class ACPMSumDataViewer implements ILazyContentProvider
// if the cache is reset during processing by an event. The request
// for data will be re-issued.
fDataExecutor.execute(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
new Transaction<String>() {
@Override
protected String process()
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncDataViewer.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncDataViewer.java
index d19ef9920a..19575fb483 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncDataViewer.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncDataViewer.java
@@ -79,16 +79,19 @@ public class AsyncDataViewer
fDataGenerator.addListener(this);
}
- public void dispose() {
+ @Override
+ public void dispose() {
fDataGenerator.removeListener(this);
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Set the initial count to the viewer after the input is set.
queryItemCount();
}
- public void updateElement(final int index) {
+ @Override
+ public void updateElement(final int index) {
// Calculate the visible index range.
final int topIdx = fViewer.getTable().getTopIndex();
final int botIdx = topIdx + getVisibleItemCount(topIdx);
@@ -100,7 +103,8 @@ public class AsyncDataViewer
// calls to be combined together improving performance of the viewer.
fCancelCallsPending++;
fDisplayExecutor.schedule(
- new Runnable() { public void run() {
+ new Runnable() { @Override
+ public void run() {
cancelStaleRequests(topIdx, botIdx);
}},
1, TimeUnit.MILLISECONDS);
@@ -120,19 +124,22 @@ public class AsyncDataViewer
itemCount - top);
}
- @ThreadSafe
+ @Override
+ @ThreadSafe
public void countChanged() {
queryItemCount();
}
- @ThreadSafe
+ @Override
+ @ThreadSafe
public void valuesChanged(final Set<Integer> indexes) {
// Mark the changed items in table viewer as dirty, this will
// trigger update requests for these indexes if they are
// visible in the viewer.
final TableViewer tableViewer = fViewer;
fDisplayExecutor.execute( new Runnable() {
- public void run() {
+ @Override
+ public void run() {
if (!fViewer.getTable().isDisposed()) {
for (Integer index : indexes) {
tableViewer.clear(index);
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataGenerator.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataGenerator.java
index 1d8a84c49e..35f6891713 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataGenerator.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataGenerator.java
@@ -52,11 +52,13 @@ public class AsyncSumDataGenerator implements IDataGenerator {
fDataGenerators = generators;
}
- public void getCount(final DataRequestMonitor<Integer> rm) {
+ @Override
+ public void getCount(final DataRequestMonitor<Integer> rm) {
// Artificially delay the retrieval of the sum data to simulate
// real processing time.
fExecutor.schedule( new Runnable() {
- public void run() {
+ @Override
+ public void run() {
doGetCount(rm);
}
},
@@ -102,12 +104,14 @@ public class AsyncSumDataGenerator implements IDataGenerator {
crm.setDoneCount(fDataGenerators.length);
}
- public void getValue(final int index, final DataRequestMonitor<Integer> rm)
+ @Override
+ public void getValue(final int index, final DataRequestMonitor<Integer> rm)
{
// Artificially delay the retrieval of the sum data to simulate
// real processing time.
fExecutor.schedule( new Runnable() {
- public void run() {
+ @Override
+ public void run() {
doGetValue(index, rm);
}
},
@@ -156,15 +160,18 @@ public class AsyncSumDataGenerator implements IDataGenerator {
crm.setDoneCount(fDataGenerators.length);
}
- public void shutdown(RequestMonitor rm) {
+ @Override
+ public void shutdown(RequestMonitor rm) {
rm.done();
}
- public void addListener(final Listener listener) {
+ @Override
+ public void addListener(final Listener listener) {
// no events generated
}
- public void removeListener(Listener listener) {
+ @Override
+ public void removeListener(Listener listener) {
// no events generated
}
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataViewer.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataViewer.java
index c34252562e..e64c9ede07 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataViewer.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/AsyncSumDataViewer.java
@@ -95,14 +95,16 @@ public class AsyncSumDataViewer implements ILazyContentProvider
// Schedule a task to refresh the viewer periodically.
fRefreshFuture = fDisplayExecutor.scheduleAtFixedRate(
new Runnable() {
- public void run() {
+ @Override
+ public void run() {
queryItemCount();
}
},
UPDATE_INTERVAL, UPDATE_INTERVAL, TimeUnit.MILLISECONDS);
}
- public void dispose() {
+ @Override
+ public void dispose() {
// Cancel the periodic task of refreshing the view.
fRefreshFuture.cancel(false);
@@ -113,12 +115,14 @@ public class AsyncSumDataViewer implements ILazyContentProvider
fItemDataRequestMonitors.clear();
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Set the initial count to the viewer after the input is set.
queryItemCount();
}
- public void updateElement(final int index) {
+ @Override
+ public void updateElement(final int index) {
// Calculate the visible index range.
final int topIdx = fViewer.getTable().getTopIndex();
final int botIdx = topIdx + getVisibleItemCount(topIdx);
@@ -130,7 +134,8 @@ public class AsyncSumDataViewer implements ILazyContentProvider
// calls to be combined together improving performance of the viewer.
fCancelCallsPending++;
fDisplayExecutor.execute(
- new Runnable() { public void run() {
+ new Runnable() { @Override
+ public void run() {
cancelStaleRequests(topIdx, botIdx);
}});
}
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorCacheManager.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorCacheManager.java
index 1e1d4e74e8..c018592b12 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorCacheManager.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorCacheManager.java
@@ -143,7 +143,8 @@ public class DataGeneratorCacheManager implements IDataGenerator.Listener {
return value;
}
- public void countChanged() {
+ @Override
+ public void countChanged() {
// Reset the count cache and all the value caches.
if (fCountCache != null) {
fCountCache.countChanged();
@@ -153,7 +154,8 @@ public class DataGeneratorCacheManager implements IDataGenerator.Listener {
}
}
- public void valuesChanged(Set<Integer> indexes) {
+ @Override
+ public void valuesChanged(Set<Integer> indexes) {
// Reset selected value caches.
for (Integer index : indexes) {
ValueCache value = fValueCaches.get(index);
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java
index 57307efa33..6df09bd322 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java
@@ -72,9 +72,11 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
fRequestMonitor = rm;
rm.addCancelListener(new RequestMonitor.ICanceledListener() {
- public void requestCanceled(RequestMonitor rm) {
+ @Override
+ public void requestCanceled(RequestMonitor rm) {
fExecutor.execute(new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
fQueue.remove(Request.this);
}
});
@@ -184,7 +186,8 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
// Schedule a runnable to make the random changes.
fExecutor.scheduleAtFixedRate(
new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
randomChanges();
}
},
@@ -197,10 +200,12 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
// indicating allowed thread access to this class/method/member
//#endif
- public void shutdown(final RequestMonitor rm) {
+ @Override
+ public void shutdown(final RequestMonitor rm) {
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
// Empty the queue of requests and fail them.
for (Request request : fQueue) {
request.fRequestMonitor.setStatus(new Status(
@@ -226,10 +231,12 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
// indicating allowed thread access to this class/method/member
//#endif
- public void getCount(final DataRequestMonitor<Integer> rm) {
+ @Override
+ public void getCount(final DataRequestMonitor<Integer> rm) {
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
fQueue.add(new CountRequest(rm));
serviceQueue();
}
@@ -246,10 +253,12 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
// indicating allowed thread access to this class/method/member
//#endif
- public void getValue(final int index, final DataRequestMonitor<Integer> rm) {
+ @Override
+ public void getValue(final int index, final DataRequestMonitor<Integer> rm) {
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
fQueue.add(new ItemRequest(index, rm));
serviceQueue();
}
@@ -265,10 +274,12 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
// indicating allowed thread access to this class/method/member
//#endif
- public void addListener(final Listener listener) {
+ @Override
+ public void addListener(final Listener listener) {
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
fListeners.add(listener);
}
});
@@ -279,10 +290,12 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor)
// indicating allowed thread access to this class/method/member
//#endif
- public void removeListener(final Listener listener) {
+ @Override
+ public void removeListener(final Listener listener) {
try {
fExecutor.execute( new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
fListeners.remove(listener);
}
});
@@ -299,7 +312,8 @@ public class DataGeneratorWithExecutor implements IDataGenerator {
private void serviceQueue() {
fExecutor.schedule(
new DsfRunnable() {
- public void run() {
+ @Override
+ public void run() {
doServiceQueue();
}
},
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java
index 066d3cc37b..f064ba286c 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java
@@ -82,7 +82,7 @@ public class DataGeneratorWithThread extends Thread
new LinkedBlockingQueue<Request>();
// ListenerList class provides thread safety.
- private ListenerList fListeners = new ListenerList();
+ private ListenerList<Listener> fListeners = new ListenerList<>();
// Current number of elements in this generator.
private int fCount = MIN_COUNT;
@@ -105,7 +105,8 @@ public class DataGeneratorWithThread extends Thread
start();
}
- public void shutdown(RequestMonitor rm) {
+ @Override
+ public void shutdown(RequestMonitor rm) {
// Mark the generator as shut down. After the fShutdown flag is set,
// all new requests should be shut down.
if (!fShutdown.getAndSet(true)) {
@@ -118,7 +119,8 @@ public class DataGeneratorWithThread extends Thread
}
}
- public void getCount(DataRequestMonitor<Integer> rm) {
+ @Override
+ public void getCount(DataRequestMonitor<Integer> rm) {
if (!fShutdown.get()) {
fQueue.add(new CountRequest(rm));
} else {
@@ -128,7 +130,8 @@ public class DataGeneratorWithThread extends Thread
}
}
- public void getValue(int index, DataRequestMonitor<Integer> rm) {
+ @Override
+ public void getValue(int index, DataRequestMonitor<Integer> rm) {
if (!fShutdown.get()) {
fQueue.add(new ItemRequest(index, rm));
} else {
@@ -138,11 +141,13 @@ public class DataGeneratorWithThread extends Thread
}
}
- public void addListener(Listener listener) {
+ @Override
+ public void addListener(Listener listener) {
fListeners.add(listener);
}
- public void removeListener(Listener listener) {
+ @Override
+ public void removeListener(Listener listener) {
fListeners.remove(listener);
}
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/SyncDataViewer.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/SyncDataViewer.java
index 335d198415..8523947a54 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/SyncDataViewer.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/SyncDataViewer.java
@@ -56,12 +56,14 @@ public class SyncDataViewer
fDataGenerator.addListener(this);
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Not used
}
- public Object[] getElements(Object inputElement) {
+ @Override
+ public Object[] getElements(Object inputElement) {
// Create the query object for reading data count.
Query<Integer> countQuery = new Query<Integer>() {
@@ -126,16 +128,19 @@ public class SyncDataViewer
return new Object[0];
}
- public void dispose() {
+ @Override
+ public void dispose() {
fDataGenerator.removeListener(this);
}
- public void countChanged() {
+ @Override
+ public void countChanged() {
// For any event from the generator, refresh the whole viewer.
refreshViewer();
}
- public void valuesChanged(Set<Integer> indexes) {
+ @Override
+ public void valuesChanged(Set<Integer> indexes) {
// For any event from the generator, refresh the whole viewer.
refreshViewer();
}
@@ -151,7 +156,8 @@ public class SyncDataViewer
// thread before calling the viewer.
Display display = fViewer.getControl().getDisplay();
display.asyncExec( new Runnable() {
- public void run() {
+ @Override
+ public void run() {
if (!fViewer.getControl().isDisposed()) {
fViewer.refresh();
}

Back to the top