use of org.knime.workbench.explorer.dialogs.Validator in project knime-core by knime.
the class SaveAsMetaNodeTemplateAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
if (nodes.length < 1) {
return;
}
WorkflowManager wm = Wrapper.unwrapWFM(nodes[0].getNodeContainer());
List<String> validMountPointList = new ArrayList<String>();
// Workbench.getInstance().getActiveWorkbenchWindow().getActivePage().findView(ID)
for (Map.Entry<String, AbstractContentProvider> entry : ExplorerMountTable.getMountedContent().entrySet()) {
AbstractContentProvider contentProvider = entry.getValue();
if (contentProvider.isWritable() && contentProvider.canHostMetaNodeTemplates()) {
validMountPointList.add(entry.getKey());
}
}
if (validMountPointList.isEmpty()) {
throw new IllegalStateException("No valid mount points found - " + "this is inconsistent with calculateEnabled()");
}
String[] validMountPoints = validMountPointList.toArray(new String[0]);
final Shell shell = Display.getCurrent().getActiveShell();
ContentObject defSel = getDefaultSaveLocation(wm);
SpaceResourceSelectionDialog dialog = new SpaceResourceSelectionDialog(shell, validMountPoints, defSel);
dialog.setTitle("Save As Metanode Template");
dialog.setHeader("Select destination workflow group for metanode template");
dialog.setValidator(new Validator() {
@Override
public String validateSelectionValue(final AbstractExplorerFileStore selection, final String name) {
final AbstractExplorerFileInfo info = selection.fetchInfo();
if (info.isWorkflowGroup()) {
return null;
}
return "Only workflow groups can be selected as target.";
}
});
if (dialog.open() != Window.OK) {
return;
}
AbstractExplorerFileStore target = dialog.getSelection();
AbstractContentProvider contentProvider = target.getContentProvider();
contentProvider.saveMetaNodeTemplate(wm, target);
}
use of org.knime.workbench.explorer.dialogs.Validator in project knime-core by knime.
the class SaveAsSubNodeTemplateAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
if (nodes.length < 1) {
return;
}
SubNodeContainer snc = unwrap(nodes[0].getNodeContainer(), SubNodeContainer.class);
WorkflowManager wm = snc.getWorkflowManager();
List<String> validMountPointList = new ArrayList<String>();
for (Map.Entry<String, AbstractContentProvider> entry : ExplorerMountTable.getMountedContent().entrySet()) {
AbstractContentProvider contentProvider = entry.getValue();
if (contentProvider.isWritable() && contentProvider.canHostMetaNodeTemplates()) {
validMountPointList.add(entry.getKey());
}
}
if (validMountPointList.isEmpty()) {
throw new IllegalStateException("No valid mount points found - " + "this is inconsistent with calculateEnabled()");
}
String[] validMountPoints = validMountPointList.toArray(new String[0]);
final Shell shell = Display.getCurrent().getActiveShell();
ContentObject defSel = getDefaultSaveLocation(wm);
SpaceResourceSelectionDialog dialog = new SpaceResourceSelectionDialog(shell, validMountPoints, defSel);
dialog.setTitle("Save As Wrapped Metanode Template");
dialog.setHeader("Select destination workflow group for Wrapped Metanode template");
dialog.setValidator(new Validator() {
@Override
public String validateSelectionValue(final AbstractExplorerFileStore selection, final String name) {
final AbstractExplorerFileInfo info = selection.fetchInfo();
if (info.isWorkflowGroup()) {
return null;
}
return "Only workflow groups can be selected as target.";
}
});
if (dialog.open() != Window.OK) {
return;
}
AbstractExplorerFileStore target = dialog.getSelection();
AbstractContentProvider contentProvider = target.getContentProvider();
contentProvider.saveSubNodeTemplate(snc, target);
}
Aggregations