Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Refactoring and cleanup #49

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f5e223a
Refactor scijava integration
dietzc Aug 29, 2016
ff8a056
Add javadoc to everything and cleanup.
Squareys Sep 12, 2016
82eeeac
Rename ConverterCacheService to KNIMEConverterService
Squareys Sep 12, 2016
3fbb32d
Avoid deprecated setResolved method
Squareys Sep 12, 2016
f23b70d
Always use NodeModuleOutputChangedListener, even for single row outputs
Squareys Sep 12, 2016
b3c4f7a
Pre is never null
Squareys Sep 12, 2016
215d97f
Fix MultiOutputListener @Parameters not being marked resolved
Squareys Sep 12, 2016
fe6e1bb
Avoid deprecated ResourceAwareClassLoader constructor
Squareys Sep 12, 2016
fbd8bef
Move per-node-execution preprocessing into private method.
Squareys Sep 12, 2016
c811481
Fix tiny bug
Squareys Sep 12, 2016
76acbea
Rename KnimeProcessorTest to NodeModuleTest
Squareys Sep 12, 2016
8d9bfd4
Avoid null checking getWidgetStyle()
Squareys Sep 12, 2016
24bc5ad
More javadoc
Squareys Sep 12, 2016
488620f
Use NodeLogger for logging in NodeModules and implement KNIMELogService
Squareys Sep 12, 2016
feeafa9
NodeModuleTest: Adapt to API changes in org.knime.scijava.commands
Squareys Sep 12, 2016
2bd9815
Specify 'manualPush' in constructor instead of setter.
Squareys Sep 12, 2016
6ea385c
Add tests for NodeModule and DefaultNodeModuleService
Squareys Sep 13, 2016
71e1053
Add getPreferredDataType(Class) to KNIMEConverterService
Squareys Sep 13, 2016
d2420bc
Delegate exception during notifyListener()
Squareys Sep 13, 2016
624b28f
Simplyfy getting output DataType for module output.
Squareys Sep 13, 2016
911fe46
Some Code cleanup
Squareys Sep 13, 2016
4e0736e
Remove unused imports
Squareys Sep 13, 2016
255e9fc
Use better way of detecting synthetic "result" ouput
Squareys Sep 26, 2016
321c004
Merge branch 'master' into refactoring-and-cleanup
dietzc Dec 4, 2016
a1480f0
fixes
dietzc Dec 4, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.knime.core.data.def.IntCell;
import org.knime.core.data.def.LongCell;
import org.knime.core.data.def.StringCell;
import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.knime.scijava.commands.io.DefaultInputDataRowService;
import org.knime.scijava.commands.io.DefaultOutputDataRowService;
import org.knime.scijava.commands.io.InputDataRowService;
Expand Down Expand Up @@ -60,7 +60,7 @@ public class KnimeProcessorTest {

protected static List<Class<? extends Service>> requiredServices = Arrays.<Class<? extends Service>> asList(
DefaultInputDataRowService.class, DefaultOutputDataRowService.class, CommandService.class,
ConverterCacheService.class);
KNIMEConverterService.class);

// Create the test table
private static final DataRow m_testRow = new DefaultRow(new RowKey("TestRow001"), BooleanCell.TRUE, new IntCell(42),
Expand All @@ -72,7 +72,7 @@ public class KnimeProcessorTest {

@BeforeClass
public static void setUpOnce() {
ResourceAwareClassLoader cl = new ResourceAwareClassLoader(Thread.currentThread().getContextClassLoader());
ResourceAwareClassLoader cl = new ResourceAwareClassLoader(Thread.currentThread().getContextClassLoader(), KnimeProcessorTest.class);

context = new Context(requiredServices, new PluginIndex(new DefaultPluginFinder(cl)));
}
Expand Down
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,19 @@
package org.knime.scijava.commands;

import org.knime.core.data.DataCell;

/**
* Interface for classes which are able to receive cells as output.
*
* @author Christian Dietz, University of Konstanz
*/
public interface CellOutput {

/**
* Push a new row of output.
*
* @param cells
* The cells which make the output row
*/
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,15 @@
package org.knime.scijava.commands;

/**
* Interface for classes which listen to pushes of output rows.
*
* @author Christian Dietz, University of Konstanz
* @see CellOutput
*/
public interface MultiOutputListener {

/**
* Notify this listener that a new output row has been pushed.
*/
public void notifyListener();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
import java.util.Arrays;
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.converter.KNIMEConverterService;
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,12 +18,15 @@
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;

/**
* Gateway to the SciJava world
* Gateway to the SciJava world.
*
* @author Christian Dietz, University of Konstanz
*/
public class SciJavaGateway {

Expand All @@ -50,15 +49,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,
ConverterCacheService.class, CommandService.class,
NodeModelSettingsService.class,
SettingsModelTypeService.class,
SimpleColumnMappingService.class);
.<Class<? extends Service>> asList(PrefService.class,
ObjectService.class, WidgetService.class, UIService.class,
KNIMEConverterService.class, CommandService.class,
NodeModuleService.class, SettingsModelTypeService.class,
NodeSettingsService.class, ScriptService.class);

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

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

Expand All @@ -117,5 +112,4 @@ private Context getGlobalContext() {
public ResourceAwareClassLoader getClassLoader() {
return m_classLoader;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

package org.knime.scijava.commands;

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

/**
*
* Example Command to be wrapped as KNIME Node.
*
* @author Christian Dietz, University of Konstanz
*/
@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,17 @@
package org.knime.scijava.commands;

import org.knime.scijava.commands.widget.ColumnSelectionWidget;
import org.scijava.plugin.Parameter;

/**
* StyleHook constants for {@link Parameter#style()}.
*
* @author Christian Dietz, University of Konstanz
*/
public interface StyleHook {
/**
* Force the parameter to be filled by a input column. Will result in the
* {@link ColumnSelectionWidget} being used as for it.
*/
public final static String COLUMNSELECTION = "colSel";
}
Loading