use of org.knime.workbench.editor2.WizardNodeView in project knime-core by knime.
the class OpenInteractiveWebViewAction method getConfiguredWizardNodeView.
@SuppressWarnings({ "rawtypes", "unchecked" })
static AbstractWizardNodeView getConfiguredWizardNodeView(final ViewableModel model) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] configurationElements = registry.getConfigurationElementsFor("org.knime.core.WizardNodeView");
Class<?> viewClass = null;
String classString = JSCorePlugin.getDefault().getPreferenceStore().getString(JSCorePlugin.P_VIEW_BROWSER);
if (StringUtils.isNotEmpty(classString)) {
// try loading selected view
viewClass = getViewClassByReflection(classString, configurationElements);
if (viewClass == null) {
LOGGER.error("JS view set in preferences (" + classString + ") can't be loaded. Switching to default.");
}
}
if (viewClass == null) {
// try loading defaults
viewClass = getViewClassByReflection(CHROMIUM_BROWSER, configurationElements);
if (viewClass == null) {
viewClass = getViewClassByReflection(CHROME_BROWSER, configurationElements);
try {
Method isChromePresentM = viewClass.getMethod("isChromePresent");
boolean isChromePresent = (boolean) isChromePresentM.invoke(null);
if (!isChromePresent) {
// no Chrome found on system, defaulting to SWT browser
viewClass = null;
}
} catch (Exception e) {
/* do nothing */
}
}
}
if (viewClass != null) {
try {
Method isEnabledM = viewClass.getMethod("isEnabled");
boolean isEnabled = (boolean) isEnabledM.invoke(null);
if (!isEnabled) {
LOGGER.error("JS view (" + classString + ") is not available. Falling back to internal SWT browser.");
viewClass = null;
}
} catch (Exception e) {
/*do nothing */
}
}
if (viewClass != null) {
try {
Constructor<?> constructor = viewClass.getConstructor(ViewableModel.class);
return (AbstractWizardNodeView) constructor.newInstance(model);
} catch (Exception e) {
LOGGER.error("JS view can not be initialized. Falling back to internal SWT browser.");
}
}
return new WizardNodeView(model);
}
Aggregations