use of org.knime.core.node.workflow.NodeContainer in project knime-core by knime.
the class ChangeSubNodeLinkCommand method setLink.
private boolean setLink(final URI link) {
NodeContainer subNode = getHostWFM().getNodeContainer(m_subNodeID);
if (!(subNode instanceof SubNodeContainer)) {
LOGGER.error("Command failed: Specified node is not a Wrapped Metanode");
return false;
}
MetaNodeTemplateInformation templateInfo = ((SubNodeContainer) subNode).getTemplateInformation();
MetaNodeTemplateInformation newInfo;
try {
newInfo = templateInfo.createLinkWithUpdatedSource(m_newLink);
} catch (InvalidSettingsException e1) {
// will not happen.
LOGGER.error("Command failed: Specified node is not a Wrapped Metanode with a link." + e1.getMessage(), e1);
return false;
}
getHostWFM().setTemplateInformation(m_subNodeID, newInfo);
return true;
}
use of org.knime.core.node.workflow.NodeContainer in project knime-core by knime.
the class DisconnectMetaNodeLinkCommand method canExecute.
/**
* We can execute, if all components were 'non-null' in the constructor.
* {@inheritDoc}
*/
@Override
public boolean canExecute() {
if (!super.canExecute()) {
return false;
}
if (m_ids == null) {
return false;
}
for (NodeID id : m_ids) {
NodeContainer nc = getHostWFM().getNodeContainer(id);
if (nc instanceof WorkflowManager) {
WorkflowManager wm = (WorkflowManager) nc;
MetaNodeTemplateInformation lI = wm.getTemplateInformation();
if (Role.Link.equals(lI.getRole())) {
return true;
}
}
}
return false;
}
use of org.knime.core.node.workflow.NodeContainer in project knime-core by knime.
the class HorizAlignCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
Map<NodeID, NodeUIInformation> oldPositions = m_alignMgr.getOldNodeCoordinates();
Map<ConnectionID, ConnectionUIInformation> oldBendpoints = m_alignMgr.getOldBendpoints();
// re-position nodes
for (Map.Entry<NodeID, NodeUIInformation> e : oldPositions.entrySet()) {
NodeContainer nc = m_wfm.getNodeContainer(e.getKey());
if (nc == null) {
continue;
}
nc.setUIInformation(e.getValue());
}
// re-create bendpoints
for (Map.Entry<ConnectionID, ConnectionUIInformation> e : oldBendpoints.entrySet()) {
ConnectionContainer cc = m_wfm.getConnection(e.getKey());
if (cc == null) {
continue;
}
cc.setUIInfo(e.getValue());
}
}
use of org.knime.core.node.workflow.NodeContainer in project knime-core by knime.
the class VerticAlignCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
Map<NodeID, NodeUIInformation> oldPositions = m_alignMgr.getOldNodeCoordinates();
Map<ConnectionID, ConnectionUIInformation> oldBendpoints = m_alignMgr.getOldBendpoints();
// re-position nodes
for (Map.Entry<NodeID, NodeUIInformation> e : oldPositions.entrySet()) {
NodeContainer nc = m_wfm.getNodeContainer(e.getKey());
if (nc == null) {
continue;
}
nc.setUIInformation(e.getValue());
}
// re-create bendpoints
for (Map.Entry<ConnectionID, ConnectionUIInformation> e : oldBendpoints.entrySet()) {
ConnectionContainer cc = m_wfm.getConnection(e.getKey());
if (cc == null) {
continue;
}
cc.setUIInfo(e.getValue());
}
}
use of org.knime.core.node.workflow.NodeContainer in project knime-core by knime.
the class SubnodeLayoutJSONEditorPage method fillBasicComposite.
private void fillBasicComposite() {
if (!m_basicPanelAvailable) {
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = SWT.CENTER;
Label infoLabel = new Label(m_basicComposite, SWT.CENTER);
infoLabel.setText("A basic configuration of the layout is not possible. \nPlease use the \"Advanced\" tab.");
infoLabel.setLayoutData(gridData);
return;
}
m_basicComposite.setLayout(new GridLayout(7, false));
m_basicComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
Label titleLabel = new Label(m_basicComposite, SWT.LEFT);
FontData fontData = titleLabel.getFont().getFontData()[0];
Font boldFont = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
titleLabel.setText("Node");
titleLabel.setFont(boldFont);
new Composite(m_basicComposite, SWT.NONE);
/* Warning placeholder */
Label rowLabel = new Label(m_basicComposite, SWT.CENTER);
rowLabel.setText("Row");
rowLabel.setFont(boldFont);
Label colLabel = new Label(m_basicComposite, SWT.CENTER);
colLabel.setText("Column");
colLabel.setFont(boldFont);
Label widthLabel = new Label(m_basicComposite, SWT.CENTER);
widthLabel.setText("Width");
widthLabel.setFont(boldFont);
new Composite(m_basicComposite, SWT.NONE);
/* More placeholder */
new Composite(m_basicComposite, SWT.NONE);
for (final Entry<NodeIDSuffix, BasicLayoutInfo> entry : m_basicMap.entrySet()) {
NodeIDSuffix suffix = entry.getKey();
BasicLayoutInfo layoutInfo = entry.getValue();
NodeID nodeID = suffix.prependParent(m_subNodeContainer.getWorkflowManager().getID());
NodeContainer nodeContainer = m_viewNodes.containsKey(suffix) ? m_wfManager.getNodeContainer(nodeID) : null;
createNodeLabelComposite(m_basicComposite, nodeID, nodeContainer);
final Label warningLabel = new Label(m_basicComposite, SWT.CENTER);
if (nodeContainer != null && m_viewNodes.get(suffix).isHideInWizard()) {
warningLabel.setImage(ImageRepository.getIconImage(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout/warning.png"));
warningLabel.setToolTipText("Node is set to 'Hide in Wizard'. It might not be displayed in the layout.");
}
GridData gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gridData.widthHint = 50;
final Spinner rowSpinner = createBasicPanelSpinner(m_basicComposite, layoutInfo.getRow(), 1, 999);
rowSpinner.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
layoutInfo.setRow(rowSpinner.getSelection());
tryUpdateJsonFromBasic();
}
});
final Spinner colSpinner = createBasicPanelSpinner(m_basicComposite, layoutInfo.getCol(), 1, 99);
colSpinner.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
layoutInfo.setCol(colSpinner.getSelection());
tryUpdateJsonFromBasic();
}
});
final Spinner widthSpinner = createBasicPanelSpinner(m_basicComposite, layoutInfo.getColWidth(), 1, 12);
widthSpinner.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
layoutInfo.setColWidth(widthSpinner.getSelection());
tryUpdateJsonFromBasic();
}
});
final Button advancedButton = new Button(m_basicComposite, SWT.PUSH | SWT.CENTER);
advancedButton.setImage(ImageRepository.getIconImage(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout/settings.png"));
advancedButton.setToolTipText("Additional layout settings");
if (nodeContainer == null) {
advancedButton.setEnabled(false);
} else {
advancedButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
JSONLayoutViewContent defaultViewContent = m_layoutCreator.getDefaultViewContentForNode(suffix, m_viewNodes.get(suffix));
ViewContentSettingsDialog settingsDialog = new ViewContentSettingsDialog(m_basicComposite.getShell(), layoutInfo.getView(), defaultViewContent);
if (settingsDialog.open() == Window.OK) {
layoutInfo.setView(settingsDialog.getViewSettings());
tryUpdateJsonFromBasic();
}
}
});
}
final Button removeButton = new Button(m_basicComposite, SWT.PUSH | SWT.CENTER);
removeButton.setImage(ImageRepository.getIconImage(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout/remove.png"));
removeButton.setToolTipText("Remove node from layout");
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (nodeContainer != null) {
if (!MessageDialog.openConfirm(m_basicComposite.getShell(), "Confirm deletion", "Are you sure you want to delete node " + suffix + " from the layout?")) {
return;
}
}
m_basicMap.remove(suffix);
tryUpdateJsonFromBasic();
}
});
}
for (@SuppressWarnings("rawtypes") final Entry<NodeIDSuffix, WizardNode> entry : m_viewNodes.entrySet()) {
if (m_basicMap.containsKey(entry.getKey())) {
continue;
}
// Node not in layout
NodeID nodeID = entry.getKey().prependParent(m_subNodeContainer.getWorkflowManager().getID());
NodeContainer nodeContainer = m_wfManager.getNodeContainer(nodeID);
createNodeLabelComposite(m_basicComposite, nodeID, nodeContainer);
final Label warningLabel = new Label(m_basicComposite, SWT.CENTER);
if (nodeContainer != null && m_viewNodes.get(entry.getKey()).isHideInWizard()) {
warningLabel.setImage(ImageRepository.getIconImage(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout/warning.png"));
warningLabel.setToolTipText("Node is set to 'Hide in Wizard'. It might not be displayed in the layout.");
}
final Button addButton = new Button(m_basicComposite, SWT.PUSH | SWT.CENTER);
addButton.setImage(ImageRepository.getIconImage(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout/add.png"));
addButton.setToolTipText("Add node to layout");
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
int lastRow = 0;
for (BasicLayoutInfo basicLayoutInfo : m_basicMap.values()) {
lastRow = Math.max(lastRow, basicLayoutInfo.getRow());
}
BasicLayoutInfo newInfo = new BasicLayoutInfo();
newInfo.setRow(lastRow + 1);
newInfo.setCol(1);
newInfo.setColWidth(12);
newInfo.setView(m_layoutCreator.getDefaultViewContentForNode(entry.getKey(), entry.getValue()));
m_basicMap.put(entry.getKey(), newInfo);
tryUpdateJsonFromBasic();
}
});
GridData gridData = new GridData();
gridData.horizontalSpan = 4;
Label space = new Label(m_basicComposite, SWT.NONE);
space.setLayoutData(gridData);
}
GridData fillRow = new GridData();
fillRow.grabExcessHorizontalSpace = true;
fillRow.horizontalAlignment = SWT.CENTER;
fillRow.horizontalSpan = 7;
Button resetButton = new Button(m_basicComposite, SWT.PUSH | SWT.CENTER);
resetButton.setImage(ImageRepository.getIconImage(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout/reset.png"));
resetButton.setText("Reset");
resetButton.setToolTipText("Reset layout to default according to currently available nodes.");
resetButton.setLayoutData(fillRow);
resetButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (!MessageDialog.openConfirm(m_basicComposite.getShell(), "Confirm reset", "Are you sure you want to reset the layout according to the currently available nodes?")) {
return;
}
resetLayout();
if (isWindows()) {
m_textArea.setText(m_jsonDocument);
} else {
m_text.setText(m_jsonDocument);
}
updateModelFromJson();
}
});
}
Aggregations