Skip to content

Commit f5e223a

Browse files
dietzcSquareys
authored andcommitted
Refactor scijava integration
1 parent 4f2c7ef commit f5e223a

File tree

75 files changed

+2119
-1791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2119
-1791
lines changed

org.knime.scijava.commands/.classpath

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
44
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
55
<classpathentry excluding="org/knime/knip/scijava/commands/adapter/basic/ImgInputAdapter.java|org/knime/knip/scijava/commands/adapter/basic/ImgOutputAdapter.java|org/knime/knip/scijava/commands/adapter/basic/ImgPlusInputAdapter.java|org/knime/knip/scijava/commands/adapter/basic/ImgPlusOutputAdapter.java" kind="src" path="src"/>
6+
<classpathentry exported="true" kind="lib" path="lib/tools.jar"/>
67
<classpathentry kind="output" path="bin"/>
78
</classpath>

org.knime.scijava.commands/META-INF/MANIFEST.MF

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0",
1616
scijava-plugins-text-plain;bundle-version="0.1.2",
1717
scijava-ui-awt;bundle-version="0.1.4",
1818
scijava-ui-swing;bundle-version="0.8.0",
19-
org.knime.scijava.core;bundle-version="0.2.1"
19+
org.knime.scijava.core;bundle-version="0.2.1",
20+
com.google.guava;bundle-version="19.0.0",
21+
scripting-jython;bundle-version="0.3.0",
22+
jython-shaded;bundle-version="2.5.3",
23+
scripting-java;bundle-version="0.4.0",
24+
scripting-clojure;bundle-version="0.1.4"
2025
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
2126
Bundle-ActivationPolicy: lazy
22-
Bundle-ClassPath: scijava_commands.jar
27+
Bundle-ClassPath: scijava_commands.jar,
28+
lib/tools.jar
2329
Export-Package: org.knime.scijava.commands,
2430
org.knime.scijava.commands.adapter,
2531
org.knime.scijava.commands.adapter.basic,

org.knime.scijava.commands/build.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ bin.includes = plugin.xml,\
66
lib/,\
77
icons/,\
88
lib/mvn/scijava-common-2.1.0.jar,\
9-
scijava_commands.jar
9+
scijava_commands.jar,\
10+
lib/tools.jar
1011
output.knipknime.jar = bin/
1112
src.includes = lib/src/,\
1213
src/
17.3 MB
Binary file not shown.

org.knime.scijava.commands/plugin.xml

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<?eclipse version="3.0"?>
33
<plugin>
4+
<extension
5+
point="org.knime.workbench.repository.nodes">
6+
</extension>
7+
<extension
8+
point="org.knime.workbench.repository.nodesets">
9+
<nodeset
10+
default-category-icon="org.knime.scijava.commands.nodes.SciJavaNodeSetFactory"
11+
deprecated="false"
12+
factory-class="org.knime.scijava.commands.nodes.SciJavaNodeSetFactory"
13+
id="SciJavaNodeSet (TMP)">
14+
</nodeset>
15+
</extension>
416
</plugin>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# @double value
2+
# @OUTPUT double greeting
3+
4+
greeting = value
5+
6+
print greeting
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; @Integer(label="My integer",description="Input integer.",value=17) test-int
2+
; @OUTPUT Integer output-int
3+
4+
(def output-int test-int)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.knime.scijava.commands;
2+
3+
import org.knime.core.data.DataCell;
4+
5+
public interface CellOutput {
6+
void push(final DataCell[] cells);
7+
}

org.knime.scijava.commands/src/org/knime/scijava/commands/DefaultKnimeExecutionService.java

-47
This file was deleted.

org.knime.scijava.commands/src/org/knime/scijava/commands/KNIMEExecutionService.java

-33
This file was deleted.

org.knime.scijava.commands/src/org/knime/scijava/commands/KNIMESciJavaConstants.java

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.knime.scijava.commands;
2+
3+
public interface MultiOutputListener {
4+
public void notifyListener();
5+
}

org.knime.scijava.commands/src/org/knime/scijava/commands/SciJavaGateway.java

+7-14
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
import java.util.List;
55

66
import org.knime.scijava.commands.converter.ConverterCacheService;
7-
import org.knime.scijava.commands.io.InputDataRowService;
8-
import org.knime.scijava.commands.io.OutputDataRowService;
9-
import org.knime.scijava.commands.settings.NodeModelSettingsService;
7+
import org.knime.scijava.commands.module.NodeModuleService;
108
import org.knime.scijava.commands.settings.NodeSettingsService;
119
import org.knime.scijava.commands.settings.SettingsModelTypeService;
12-
import org.knime.scijava.commands.simplemapping.SimpleColumnMappingService;
13-
import org.knime.scijava.commands.widget.KNIMEWidgetService;
1410
import org.knime.scijava.core.ResourceAwareClassLoader;
1511
import org.knime.scijava.core.SubContext;
1612
import org.knime.scijava.core.pluginindex.ReusablePluginIndex;
@@ -22,6 +18,7 @@
2218
import org.scijava.plugin.PluginIndex;
2319
import org.scijava.plugin.PluginService;
2420
import org.scijava.prefs.PrefService;
21+
import org.scijava.script.ScriptService;
2522
import org.scijava.service.Service;
2623
import org.scijava.ui.UIService;
2724
import org.scijava.widget.WidgetService;
@@ -50,15 +47,11 @@ public class SciJavaGateway {
5047

5148
/** a list of services which need to be present in newly created contexts */
5249
protected static List<Class<? extends Service>> requiredServices = Arrays
53-
.<Class<? extends Service>> asList(InputDataRowService.class,
54-
OutputDataRowService.class, PrefService.class,
55-
KNIMEExecutionService.class, NodeSettingsService.class,
56-
ObjectService.class, WidgetService.class,
57-
KNIMEWidgetService.class, UIService.class,
50+
.<Class<? extends Service>> asList(PrefService.class,
51+
ObjectService.class, WidgetService.class, UIService.class,
5852
ConverterCacheService.class, CommandService.class,
59-
NodeModelSettingsService.class,
60-
SettingsModelTypeService.class,
61-
SimpleColumnMappingService.class);
53+
NodeModuleService.class, SettingsModelTypeService.class,
54+
NodeSettingsService.class, ScriptService.class);
6255

6356
/**
6457
* Constructor. Only to be called from {@link #get()}.
@@ -101,7 +94,7 @@ public Context createSubContext() {
10194
return context;
10295
}
10396

104-
private Context getGlobalContext() {
97+
public Context getGlobalContext() {
10598
if (m_globalContext == null) {
10699
m_globalContext = new Context(m_pluginIndex);
107100

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
package org.knime.scijava.commands;
3+
4+
import org.scijava.ItemIO;
5+
import org.scijava.command.Command;
6+
import org.scijava.plugin.Parameter;
7+
import org.scijava.plugin.Plugin;
8+
9+
@Plugin(type = Command.class, headless = true, label = "Test Command")
10+
public class SciJavaTestCommand implements Command {
11+
12+
@Parameter
13+
private MultiOutputListener rowOutput;
14+
15+
@Parameter(label = "From Text", style = StyleHook.COLUMNSELECTION)
16+
private String fromText;
17+
18+
@Parameter(label = "From Int")
19+
private int fromInt;
20+
21+
@Parameter(type = ItemIO.OUTPUT, label = "Output Int")
22+
private int outInt;
23+
24+
@Override
25+
public void run() {
26+
for (int i = 0; i < fromInt; i++) {
27+
outInt = i;
28+
rowOutput.notifyListener();
29+
}
30+
}
31+
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.knime.scijava.commands;
2+
3+
public interface StyleHook {
4+
public final static String COLUMNSELECTION = "colSel";
5+
}

org.knime.scijava.commands/src/org/knime/scijava/commands/converter/ConverterCacheService.java

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
package org.knime.scijava.commands.converter;
22

3+
import java.util.Collection;
34
import java.util.Optional;
45

56
import org.knime.core.data.DataCell;
67
import org.knime.core.data.DataType;
78
import org.knime.core.data.DataValue;
9+
import org.knime.core.data.convert.datacell.JavaToDataCellConverterFactory;
10+
import org.knime.core.data.convert.java.DataCellToJavaConverterFactory;
11+
import org.knime.core.node.ExecutionContext;
812
import org.scijava.service.Service;
913

14+
// FIXME NAMING (KNIPConverterCache?!)
15+
// FIXME CACHING (isn't implemented everywhere, yet)
16+
// FIXME can we always delegate to Jonathans implementations?
1017
public interface ConverterCacheService extends Service {
1118

1219
/**
@@ -35,7 +42,8 @@ public interface ConverterCacheService extends Service {
3542
* @throws Exception
3643
* When the conversion fails
3744
*/
38-
DataCell convertToKnime(Object in, Class<?> inType) throws Exception;
45+
DataCell convertToKnime(Object in, Class<?> inType, DataType type,
46+
ExecutionContext es) throws Exception;
3947

4048
/**
4149
* Flush all caches.
@@ -67,7 +75,22 @@ public interface ConverterCacheService extends Service {
6775
* the preferred value class
6876
* @return the matching java type
6977
*/
70-
Optional<Class<?>> getMatchingJavaType(
71-
DataType dataType);
78+
Optional<Class<?>> getMatchingJavaType(DataType dataType);
79+
80+
/**
81+
* @FIXME
82+
*
83+
* @return
84+
*/
85+
Collection<DataCellToJavaConverterFactory<?, ?>> getMatchingJavaTypes(
86+
ClassLoader loader, DataType dataType);
87+
88+
/**
89+
* FIXME
90+
*
91+
* @return
92+
*/
93+
Collection<JavaToDataCellConverterFactory<?>> getMatchingFactories(
94+
Class<?> javaType);
7295

7396
}

0 commit comments

Comments
 (0)