use of org.knime.base.node.jsnippet.util.field.JavaField in project knime-core by knime.
the class OutFieldsTable method addRow.
/**
* Adds a row using the give values as a hint.
* @param name the knime name
* @param type the Type
* @return true when the row was added successfully
*/
public boolean addRow(final String name, final Type type) {
Frame parent = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, this);
JavaField newRow = AddOutFieldDialog.openUserDialog(parent, m_model, m_spec, m_flowVars, m_flowVarsOnly);
if (null != newRow) {
return addRow(newRow);
} else {
return false;
}
}
use of org.knime.base.node.jsnippet.util.field.JavaField in project knime-core by knime.
the class JavaSnippet method createImportsSection.
/**
* Create the imports section for the snippet's document.
*/
private String createImportsSection() {
StringBuilder imports = new StringBuilder();
imports.append("// system imports\n");
for (String s : getSystemImports()) {
imports.append("import ");
imports.append(s);
imports.append(";\n");
}
imports.append("\n");
// Some custom converters may allow custom input and output JavaTypes we need to import.
final ArrayList<JavaField> fields = new ArrayList<>(m_fields.getInColFields());
fields.addAll(m_fields.getOutColFields());
fields.addAll(m_fields.getInVarFields());
fields.addAll(m_fields.getOutVarFields());
final Set<String> fieldImports = new LinkedHashSet<>();
for (JavaField field : fields) {
Class<?> fieldType = field.getJavaType();
if (fieldType == null) {
continue;
}
// Handle arrays of arrays of arrays of... AP-7012
while (fieldType.isArray()) {
fieldType = fieldType.getComponentType();
}
fieldType = ClassUtil.ensureObjectType(fieldType);
// java.lang.* is imported by default, we do not need to import that again.
if (!fieldType.getName().startsWith("java.lang")) {
fieldImports.add(fieldType.getName());
}
}
if (!fieldImports.isEmpty()) {
imports.append("// imports for input and output fields\n");
}
for (String s : fieldImports) {
imports.append("import ");
imports.append(s);
imports.append(";\n");
}
imports.append("\n");
return imports.toString();
}
use of org.knime.base.node.jsnippet.util.field.JavaField in project knime-core by knime.
the class OutFieldsTable method addRow.
/**
* Adds a row using the given flow variable as a hint.
*
* @param var the flow variable definition
* @return true when the row was added successfully
*/
public boolean addRow(final FlowVariable var) {
Frame parent = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, this);
JavaField newRow = AddOutFieldDialog.openUserDialog(parent, m_model, m_spec, m_flowVars, m_flowVarsOnly);
if (null != newRow) {
return addRow(newRow);
} else {
return false;
}
}
use of org.knime.base.node.jsnippet.util.field.JavaField in project knime-core by knime.
the class OutFieldsTable method addRow.
/**
* Adds a row using the give colSpec as a hint for the new row.
*
* @param colSpec the input column
* @return true when the row was added successfully
*/
public boolean addRow(final DataColumnSpec colSpec) {
Frame parent = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, this);
JavaField newRow = AddOutFieldDialog.openUserDialog(parent, m_model, m_spec, m_flowVars, m_flowVarsOnly);
if (null != newRow) {
return addRow(newRow);
} else {
return false;
}
}
Aggregations