use of org.knime.core.wizard.SubnodeViewableModel in project knime-core by knime.
the class TestSubnodeView method testSubnodeViewableModel.
/**
* Creates and tests the {@link SubnodeViewableModel}
* @throws Exception
*/
@Test
public void testSubnodeViewableModel() throws Exception {
initialExecute();
SubNodeContainer snc = getManager().getNodeContainer(m_subnodeID, SubNodeContainer.class, true);
SubnodeViewableModel svm = new SubnodeViewableModel(snc, "testView");
JSONWebNodePage page = svm.getViewRepresentation();
validateJSONPage(page);
SubnodeViewValue viewValue = svm.getViewValue();
assertNotNull("Combined view value should exist", viewValue);
assertNotNull("Combined view value map should exist", viewValue.getViewValues());
assertEquals("Combined view value should contain three entries", 3, viewValue.getViewValues().size());
Map<String, String> changedValueMap = new HashMap<String, String>(3);
changedValueMap.putAll(viewValue.getViewValues());
changedValueMap = changeStringInputTo("foo", changedValueMap);
SubnodeViewValue newViewValue = new SubnodeViewValue();
newViewValue.setViewValues(changedValueMap);
ValidationError validationError = svm.validateViewValue(newViewValue);
assertTrue("Validation error should be instance of CollectionValidationError", validationError instanceof CollectionValidationError);
Map<String, String> errorMap = ((CollectionValidationError) validationError).getErrorMap();
assertNotNull("Error map should exist", errorMap);
changedValueMap.putAll(viewValue.getViewValues());
changeStringInputTo(CHANGED_URL, changedValueMap);
selectRowInTable(changedValueMap);
validationError = svm.validateViewValue(newViewValue);
assertNull("There should not be any validation errors", validationError);
svm.loadViewValue(newViewValue, false);
waitWhileNodeInExecution(m_subnodeID);
assertTrue("Subnode should be executed.", getManager().getNodeContainer(m_subnodeID).getNodeContainerState().isExecuted());
validateReexecutionResult();
svm.discard();
assertNull("Page should be null after reset", svm.getViewRepresentation());
assertNull("View value should be null after reset", svm.getViewValue());
}
use of org.knime.core.wizard.SubnodeViewableModel in project knime-core by knime.
the class OpenSubnodeWebViewAction method run.
@SuppressWarnings("unchecked")
@Override
public void run() {
LOGGER.debug("Open Interactive Web Node View " + getSubnodeViewName());
try {
@SuppressWarnings("rawtypes") AbstractWizardNodeView view = null;
NodeContext.pushContext(m_nodeContainer);
try {
SubnodeViewableModel model = new SubnodeViewableModel(m_nodeContainer, getSubnodeViewName());
view = OpenInteractiveWebViewAction.getConfiguredWizardNodeView(model);
model.registerView(view);
} finally {
NodeContext.removeLastContext();
}
view.setWorkflowManagerAndNodeID(m_nodeContainer.getParent(), m_nodeContainer.getID());
final String title = m_nodeContainer.getName();
Node.invokeOpenView(view, title, OpenViewAction.getAppBoundsAsAWTRec());
} catch (Throwable t) {
final MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
mb.setText("Interactive View cannot be opened");
mb.setMessage("The interactive view cannot be opened for the following reason:\n" + t.getMessage());
mb.open();
LOGGER.error("The interactive view for node '" + m_nodeContainer.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an implementation error.", t);
}
}
Aggregations