Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
35ca6b0
Fix annotation processing when running javac without -d <directory>
dscho Oct 7, 2014
c637b29
Let Eclipse clean up AnnotationProcessor's source code
dscho Oct 7, 2014
8bbd4f8
Adapt instances of AnnotationValue in the annotation processor
dscho Oct 8, 2014
8fa230a
Merge pull request #131 from scijava/annotation-value
dscho Oct 8, 2014
d0c26b5
Merge pull request #129 from 4Quant/master
dscho Oct 11, 2014
d09c4f4
Fix OptionsTest's assumption that bar was not persisted previously
dscho Oct 11, 2014
13bf97f
Fix Javadocs
dscho Jun 27, 2014
b321573
Avoid compiler warning
dscho Jul 1, 2014
6470e08
PrefService: Provide an API for Iterables
dscho Jun 27, 2014
71ca10e
Add a data structure keeping n unique last-recently-used items
dscho Jul 2, 2014
e89f212
Add a history class for the upcoming script interpreters
dscho Jul 2, 2014
b7904e0
Add the UI-agnostic part of the script interpreters
dscho Jul 2, 2014
7e52d8f
Let LastRecentlyUsed implement the full Collection contract
dscho Jul 26, 2014
64e577c
Test LastRecentlyUsed#remove(Object)
dscho Jul 26, 2014
b7eb86a
ScriptInterpreter: remove irrelevant modifiers
ctrueden Oct 6, 2014
e7b80c6
DefaultScriptInterpreter: remove redundant javadoc
ctrueden Oct 6, 2014
52acdad
DefaultScriptInterpreter: add final keywords
ctrueden Oct 6, 2014
f998ed8
ScriptInterpreter: add missing punctuation
ctrueden Oct 6, 2014
6b186e3
ScriptInterpreter: remember the associated language
ctrueden Oct 6, 2014
b91b703
DefaultScriptInterpreter: add more final keywords
ctrueden Oct 6, 2014
f9c3057
Script Interpreter: keep a record of a 'current command'
dscho Oct 14, 2014
a571896
Merge pull request #127 from scijava/interpreter
dscho Oct 15, 2014
dc938f1
Bump to next development cycle
dscho Oct 15, 2014
2bc186d
Add an ol' classic: ReflectedUniverse, aka CurtisJ
ctrueden Oct 24, 2014
ea3c750
ReflectedUniverse: remove LogService usage
ctrueden Oct 24, 2014
44d2aaf
POM: bump to the latest pom-scijava 4.2 release
ctrueden Oct 24, 2014
2d16186
Bump to next development cycle
ctrueden Oct 24, 2014
11e439c
ShadowMenu: avoid NPE when child module is null
ctrueden Oct 30, 2014
bce7b69
AbstractUIDetails: fix potential comparison NPE
ctrueden Nov 4, 2014
93c340f
AbstractUIDetails: do not let getTitle return null
ctrueden Nov 4, 2014
0b033f1
Merge pull request #126 from scijava/javac-annotations
ctrueden Nov 12, 2014
e9bc21f
Bump to latest pom-scijava
hinerm Nov 14, 2014
28759bc
Bump to next development cycle
hinerm Nov 14, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>3.6</version>
<version>5.1</version>
<relativePath />
</parent>

<artifactId>scijava-common</artifactId>
<version>2.33.1-SNAPSHOT</version>
<version>2.35.2-SNAPSHOT</version>

<name>SciJava Common</name>
<description>SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO.</description>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/scijava/AbstractUIDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public String getTitle() {

// use the unique identifier, if available
if (this instanceof Identifiable) {
return ((Identifiable) this).getIdentifier();
final String id = ((Identifiable) this).getIdentifier();
if (id != null) return id;
}

// use class name as a last resort
Expand Down Expand Up @@ -235,7 +236,7 @@ public int compareTo(final Prioritized that) {
// compare titles
final String thisTitle = getTitle();
final String thatTitle = uiDetails.getTitle();
return thisTitle.compareTo(thatTitle);
return MiscUtils.compare(thisTitle, thatTitle);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import java.util.Map.Entry;
import java.util.TreeMap;

import javax.lang.model.element.AnnotationValue;

/**
* Writes annotations as JSON-formatted files.
* <p>
Expand Down Expand Up @@ -170,6 +172,9 @@ protected Object adapt(final Object o) {
if (o instanceof Annotation) {
return adapt((Annotation) o);
}
else if (o instanceof AnnotationValue) {
return adapt(((AnnotationValue) o).getValue());
}
else if (o instanceof Enum) {
return adapt((Enum<?>) o);
}
Expand Down
52 changes: 40 additions & 12 deletions src/main/java/org/scijava/annotations/AnnotationProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
package org.scijava.annotations;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -62,6 +64,7 @@
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import javax.tools.Diagnostic.Kind;
import javax.tools.FileObject;
import javax.tools.StandardLocation;

import org.scijava.annotations.AbstractIndexWriter.StreamFactory;
Expand Down Expand Up @@ -90,14 +93,14 @@ public boolean process(final Set<? extends TypeElement> elements,
try {
writer.write(writer);
}
catch (IOException e) {
catch (final IOException e) {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(out));
try {
out.close();
processingEnv.getMessager().printMessage(Kind.ERROR, out.toString());
}
catch (IOException e2) {
catch (final IOException e2) {
processingEnv.getMessager().printMessage(Kind.ERROR,
e2.getMessage() + " while printing " + e.getMessage());
}
Expand Down Expand Up @@ -152,8 +155,9 @@ public void add(final TypeElement element) {
}

@SuppressWarnings("unchecked")
private Map<String, Object> adapt(List<? extends AnnotationMirror> mirrors,
TypeMirror annotationType)
private Map<String, Object> adapt(
final List<? extends AnnotationMirror> mirrors,
final TypeMirror annotationType)
{
final Map<String, Object> result = new TreeMap<String, Object>();
for (final AnnotationMirror mirror : mirrors) {
Expand Down Expand Up @@ -208,7 +212,8 @@ else if (o instanceof VariableElement) {
}

private AnnotationMirror getMirror(final TypeElement element) {
for (AnnotationMirror candidate : utils.getAllAnnotationMirrors(element))
for (final AnnotationMirror candidate : utils
.getAllAnnotationMirrors(element))
{
final Name binaryName =
utils.getBinaryName((TypeElement) candidate.getAnnotationType()
Expand All @@ -221,7 +226,9 @@ private AnnotationMirror getMirror(final TypeElement element) {
}

@Override
public InputStream openInput(String annotationName) throws IOException {
public InputStream openInput(final String annotationName)
throws IOException
{
try {
return filer.getResource(StandardLocation.CLASS_OUTPUT, "",
Index.INDEX_PREFIX + annotationName).openInputStream();
Expand All @@ -232,16 +239,37 @@ public InputStream openInput(String annotationName) throws IOException {
}

@Override
public OutputStream openOutput(String annotationName) throws IOException {
public OutputStream openOutput(final String annotationName)
throws IOException
{
final List<Element> originating = originatingElements.get(annotationName);
return filer.createResource(StandardLocation.CLASS_OUTPUT, "",
Index.INDEX_PREFIX + annotationName,
originating.toArray(new Element[originating.size()]))
.openOutputStream();
final String path = Index.INDEX_PREFIX + annotationName;
final FileObject fileObject =
filer.createResource(StandardLocation.CLASS_OUTPUT, "", path,
originating.toArray(new Element[originating.size()]));

/*
* Verify that the generated file is in the META-INF/json/ subdirectory;
* Despite our asking for it explicitly, the DefaultFileManager will
* strip out the directory if javac was called without an explicit
* output directory (i.e. without <code>-d</code> option).
*/
final String uri = fileObject.toUri().toString();
if (uri != null && uri.endsWith("/" + path)) {
return fileObject.openOutputStream();
}
final String prefix =
uri.substring(0, uri.length() - annotationName.length());
final File file = new File(prefix + path);
final File parent = file.getParentFile();
if (parent != null && !parent.isDirectory() && !parent.mkdirs()) {
throw new IOException("Could not create directory: " + parent);
}
return new FileOutputStream(file);
}

@Override
public boolean isClassObsolete(String className) {
public boolean isClassObsolete(final String className) {
return false;
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/scijava/menu/ShadowMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,15 @@ private ShadowMenu addChild(final ModuleInfo info, final int depth) {
if (!leaf) child.addChild(info, depth + 1);
else if (existingChild != null) {
if (log != null) {
if (info.getPriority() == existingChild.getModuleInfo().getPriority()) {
final ModuleInfo childInfo = existingChild.getModuleInfo();
if (childInfo != null && info.getPriority() == childInfo.getPriority())
{
log.warn("ShadowMenu: menu item already exists:\n\texisting: " +
existingChild.getModuleInfo() + "\n\t ignored: " + info);
childInfo + "\n\t ignored: " + info);
}
else {
log.debug("ShadowMenu: higher-priority menu item already exists:\n" +
"\texisting: " + existingChild.getModuleInfo() + "\n\t ignored: " +
info);
"\texisting: " + childInfo + "\n\t ignored: " + info);
}
}
}
Expand Down
76 changes: 76 additions & 0 deletions src/main/java/org/scijava/prefs/DefaultPrefService.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,28 @@ public List<String> getList(final Class<?> prefClass) {
return getList(preferences);
}

@Override
public Iterable<String> getIterable(final String key) {
return getIterable((Class<?>) null, key);
}

@Override
public Iterable<String> getIterable(final Class<?> prefClass, final String key) {
final Preferences preferences = prefs(prefClass);
return getIterable(preferences.node(key));
}

@Override
public void putIterable(final Iterable<String> iterable, final String key) {
putIterable((Class<?>) null, iterable, key);
}

@Override
public void putIterable(final Class<?> prefClass, final Iterable<String> iterable, final String key) {
final Preferences preferences = prefs(prefClass);
putIterable(preferences.node(key), iterable);
}

// -- Helper methods --

private void clear(final Preferences preferences, final String key) {
Expand Down Expand Up @@ -460,6 +482,60 @@ private List<String> getList(final Preferences preferences) {
return list;
}

private void putIterable(final Preferences preferences,
final Iterable<String> iterable)
{
if (preferences == null) {
throw new IllegalArgumentException("Preferences not set.");
}
int index = 0;
for (final String value : iterable) {
preferences.put("" + index++, value == null ? null : value.toString());
}
}

private Iterable<String> getIterable(final Preferences preferences)
{
if (preferences == null) {
throw new IllegalArgumentException("Preferences not set.");
}
return new Iterable<String>() {
@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
private String value;
private int index;
{
findNext();
}

@Override
public String next() {
final String result = value;
findNext();
return result;
}

@Override
public boolean hasNext() {
return value != null;
}

@Override
public void remove() {
throw new UnsupportedOperationException();
}

private void findNext() {
if (index < 0) return;
value = preferences.get("" + index, null);
index = value == null ? -1 : index + 1;
}
};
}
};
}

private Preferences prefs(final Class<?> c) {
return Preferences.userNodeForPackage(c == null ? PrefService.class : c);
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/scijava/prefs/PrefService.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,24 @@ public interface PrefService extends SciJavaService {
* prefs.
*/
List<String> getList(Class<?> prefClass);

/**
* Puts an iterable into the preferences.
*/
void putIterable(Iterable<String> iterable, String key);

/**
* Puts an iterable into the preferences.
*/
void putIterable(Class<?> prefClass, Iterable<String> iterable, String key);

/**
* Gets an iterable from the preferences.
*/
Iterable<String> getIterable(String key);

/**
* Gets an iterable from the preferences.
*/
Iterable<String> getIterable(Class<?> prefClass, String key);
}
Loading