Skip to content

Commit

Permalink
Refactor scijava integration
Browse files Browse the repository at this point in the history
  • Loading branch information
dietzc authored and Squareys committed Sep 6, 2016
1 parent 4f2c7ef commit f5e223a
Show file tree
Hide file tree
Showing 75 changed files with 2,119 additions and 1,791 deletions.
1 change: 1 addition & 0 deletions org.knime.scijava.commands/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<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"/>
<classpathentry exported="true" kind="lib" path="lib/tools.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
10 changes: 8 additions & 2 deletions org.knime.scijava.commands/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0",
scijava-plugins-text-plain;bundle-version="0.1.2",
scijava-ui-awt;bundle-version="0.1.4",
scijava-ui-swing;bundle-version="0.8.0",
org.knime.scijava.core;bundle-version="0.2.1"
org.knime.scijava.core;bundle-version="0.2.1",
com.google.guava;bundle-version="19.0.0",
scripting-jython;bundle-version="0.3.0",
jython-shaded;bundle-version="2.5.3",
scripting-java;bundle-version="0.4.0",
scripting-clojure;bundle-version="0.1.4"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: scijava_commands.jar
Bundle-ClassPath: scijava_commands.jar,
lib/tools.jar
Export-Package: org.knime.scijava.commands,
org.knime.scijava.commands.adapter,
org.knime.scijava.commands.adapter.basic,
Expand Down
3 changes: 2 additions & 1 deletion org.knime.scijava.commands/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ bin.includes = plugin.xml,\
lib/,\
icons/,\
lib/mvn/scijava-common-2.1.0.jar,\
scijava_commands.jar
scijava_commands.jar,\
lib/tools.jar
output.knipknime.jar = bin/
src.includes = lib/src/,\
src/
Expand Down
Binary file added org.knime.scijava.commands/lib/tools.jar
Binary file not shown.
12 changes: 12 additions & 0 deletions org.knime.scijava.commands/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension
point="org.knime.workbench.repository.nodes">
</extension>
<extension
point="org.knime.workbench.repository.nodesets">
<nodeset
default-category-icon="org.knime.scijava.commands.nodes.SciJavaNodeSetFactory"
deprecated="false"
factory-class="org.knime.scijava.commands.nodes.SciJavaNodeSetFactory"
id="SciJavaNodeSet (TMP)">
</nodeset>
</extension>
</plugin>
6 changes: 6 additions & 0 deletions org.knime.scijava.commands/scripts/myjython.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @double value
# @OUTPUT double greeting

greeting = value

print greeting
4 changes: 4 additions & 0 deletions org.knime.scijava.commands/scripts/test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
; @Integer(label="My integer",description="Input integer.",value=17) test-int
; @OUTPUT Integer output-int

(def output-int test-int)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.knime.scijava.commands;

import org.knime.core.data.DataCell;

public interface CellOutput {
void push(final DataCell[] cells);
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.knime.scijava.commands;

public interface MultiOutputListener {
public void notifyListener();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
import java.util.List;

import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.io.InputDataRowService;
import org.knime.scijava.commands.io.OutputDataRowService;
import org.knime.scijava.commands.settings.NodeModelSettingsService;
import org.knime.scijava.commands.module.NodeModuleService;
import org.knime.scijava.commands.settings.NodeSettingsService;
import org.knime.scijava.commands.settings.SettingsModelTypeService;
import org.knime.scijava.commands.simplemapping.SimpleColumnMappingService;
import org.knime.scijava.commands.widget.KNIMEWidgetService;
import org.knime.scijava.core.ResourceAwareClassLoader;
import org.knime.scijava.core.SubContext;
import org.knime.scijava.core.pluginindex.ReusablePluginIndex;
Expand All @@ -22,6 +18,7 @@
import org.scijava.plugin.PluginIndex;
import org.scijava.plugin.PluginService;
import org.scijava.prefs.PrefService;
import org.scijava.script.ScriptService;
import org.scijava.service.Service;
import org.scijava.ui.UIService;
import org.scijava.widget.WidgetService;
Expand Down Expand Up @@ -50,15 +47,11 @@ public class SciJavaGateway {

/** a list of services which need to be present in newly created contexts */
protected static List<Class<? extends Service>> requiredServices = Arrays
.<Class<? extends Service>> asList(InputDataRowService.class,
OutputDataRowService.class, PrefService.class,
KNIMEExecutionService.class, NodeSettingsService.class,
ObjectService.class, WidgetService.class,
KNIMEWidgetService.class, UIService.class,
.<Class<? extends Service>> asList(PrefService.class,
ObjectService.class, WidgetService.class, UIService.class,
ConverterCacheService.class, CommandService.class,
NodeModelSettingsService.class,
SettingsModelTypeService.class,
SimpleColumnMappingService.class);
NodeModuleService.class, SettingsModelTypeService.class,
NodeSettingsService.class, ScriptService.class);

/**
* Constructor. Only to be called from {@link #get()}.
Expand Down Expand Up @@ -101,7 +94,7 @@ public Context createSubContext() {
return context;
}

private Context getGlobalContext() {
public Context getGlobalContext() {
if (m_globalContext == null) {
m_globalContext = new Context(m_pluginIndex);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

package org.knime.scijava.commands;

import org.scijava.ItemIO;
import org.scijava.command.Command;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Command.class, headless = true, label = "Test Command")
public class SciJavaTestCommand implements Command {

@Parameter
private MultiOutputListener rowOutput;

@Parameter(label = "From Text", style = StyleHook.COLUMNSELECTION)
private String fromText;

@Parameter(label = "From Int")
private int fromInt;

@Parameter(type = ItemIO.OUTPUT, label = "Output Int")
private int outInt;

@Override
public void run() {
for (int i = 0; i < fromInt; i++) {
outInt = i;
rowOutput.notifyListener();
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.knime.scijava.commands;

public interface StyleHook {
public final static String COLUMNSELECTION = "colSel";
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package org.knime.scijava.commands.converter;

import java.util.Collection;
import java.util.Optional;

import org.knime.core.data.DataCell;
import org.knime.core.data.DataType;
import org.knime.core.data.DataValue;
import org.knime.core.data.convert.datacell.JavaToDataCellConverterFactory;
import org.knime.core.data.convert.java.DataCellToJavaConverterFactory;
import org.knime.core.node.ExecutionContext;
import org.scijava.service.Service;

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

/**
Expand Down Expand Up @@ -35,7 +42,8 @@ public interface ConverterCacheService extends Service {
* @throws Exception
* When the conversion fails
*/
DataCell convertToKnime(Object in, Class<?> inType) throws Exception;
DataCell convertToKnime(Object in, Class<?> inType, DataType type,
ExecutionContext es) throws Exception;

/**
* Flush all caches.
Expand Down Expand Up @@ -67,7 +75,22 @@ public interface ConverterCacheService extends Service {
* the preferred value class
* @return the matching java type
*/
Optional<Class<?>> getMatchingJavaType(
DataType dataType);
Optional<Class<?>> getMatchingJavaType(DataType dataType);

/**
* @FIXME
*
* @return
*/
Collection<DataCellToJavaConverterFactory<?, ?>> getMatchingJavaTypes(
ClassLoader loader, DataType dataType);

/**
* FIXME
*
* @return
*/
Collection<JavaToDataCellConverterFactory<?>> getMatchingFactories(
Class<?> javaType);

}
Loading

0 comments on commit f5e223a

Please sign in to comment.