use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class VerticAlignManager method doLayout.
/**
*/
public void doLayout() {
Map<NodeContainerEditPart, Integer> offsets = VerticAlignmentCenter.doLayout(m_wfm, m_nodeParts);
// preserver the old stuff for undoers
m_oldBendpoints = new HashMap<ConnectionID, ConnectionUIInformation>();
m_oldCoordinates = new HashMap<NodeID, NodeUIInformation>();
if (offsets.isEmpty()) {
LOGGER.debug("Nodes already aligned. Doing nothing.");
return;
}
// transfer new coordinates into nodes
for (Map.Entry<NodeContainerEditPart, Integer> e : offsets.entrySet()) {
NodeContainerEditPart node = e.getKey();
NodeContainerUI nc = node.getNodeContainer();
NodeUIInformation uiInfo = nc.getUIInformation();
int[] b = uiInfo.getBounds();
NodeUIInformation newCoord = NodeUIInformation.builder().setNodeLocation(b[0] + e.getValue(), b[1], b[2], b[3]).setHasAbsoluteCoordinates(uiInfo.hasAbsoluteCoordinates()).build();
LOGGER.debug("Node " + nc + " gets alignment coordinates " + newCoord);
// save old coordinates for undo
m_oldCoordinates.put(nc.getID(), uiInfo);
// triggers gui update
nc.setUIInformation(newCoord);
}
}
use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class KnimeResourceContentProvider method getChildren.
/**
* {@inheritDoc}
*/
@Override
public Object[] getChildren(final Object element) {
if (element instanceof IFile) {
return EMPTY_ARRAY;
}
if (isKNIMEWorkflow(element)) {
IContainer project = (IContainer) element;
NodeContainerUI workflow = ProjectWorkflowMap.getWorkflowUI(project.getLocationURI());
if (workflow != null) {
// the number of contained nodes is returned
return getSortedNodeContainers(((WorkflowManagerUI) workflow).getNodeContainers());
}
} else if (element instanceof WorkflowManager) {
return getSortedNodeContainers(((WorkflowManagerUI) element).getNodeContainers());
}
return getFolders(element);
}
use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class KnimeResourceLabelProvider method getText.
/**
* {@inheritDoc}
*/
@Override
public String getText(final Object element) {
if (element instanceof NodeContainerUI) {
String output = ((NodeContainerUI) element).getName() + " (#" + ((NodeContainerUI) element).getID().getIndex() + ")";
// then it cannot be found
return output.replace(":", "_");
}
// query the element for its label
IWorkbenchAdapter adapter = getAdapter(element);
if (adapter == null) {
// $NON-NLS-1$
return "";
}
String label = adapter.getLabel(element);
// return the decorated label
return decorateText(label, element);
}
use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class KnimeResourceLabelProvider method getImage.
/**
* {@inheritDoc}
*/
@Override
public Image getImage(final Object element) {
Image img = super.getImage(element);
NodeContainerUI projectNode = null;
if (element instanceof IContainer) {
IContainer container = (IContainer) element;
if (container.exists(WORKFLOW_FILE)) {
// in any case a knime workflow or meta node (!)
projectNode = ProjectWorkflowMap.getWorkflowUI(container.getLocationURI());
if (projectNode == null && !isMetaNode(container)) {
return CLOSED_WORKFLOW;
}
}
if (projectNode == null) {
if (isMetaNode(container)) {
return NODE;
} else if (container.exists(METAINFO_FILE)) {
return WORKFLOW_GROUP;
}
}
} else if (element instanceof NodeContainerUI) {
projectNode = (NodeContainerUI) element;
}
if (projectNode != null) {
if (projectNode instanceof WorkflowManagerUI && // are displayed with state
((WorkflowManagerUI) projectNode).getID().hasSamePrefix(WorkflowManager.ROOT.getID())) {
NodeContainerState state = projectNode.getNodeContainerState();
if (projectNode.getNodeMessage().getMessageType().equals(NodeMessage.Type.ERROR)) {
return ERROR;
}
if (state.isExecuted()) {
return EXECUTED;
} else if (state.isExecutionInProgress()) {
return EXECUTING;
} else {
return CONFIGURED;
}
} else {
return NODE;
}
}
return img;
}
use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.
the class ProjectWorkflowMap method replace.
/**
* @param newPath the new path of the {@link IProject} after renaming
* @param nc the {@link WorkflowManager} with a project new associated name
* @param oldPath the old {@link IProject} path, under which the opened
* {@link WorkflowManager} is stored in the map
*/
public static void replace(final URI newPath, final WorkflowManagerUI nc, final URI oldPath) {
if (oldPath == null) {
throw new IllegalArgumentException("Old path must not be null (old is null, new is " + newPath + ")");
}
final MapWFKey oldKey = new MapWFKey(oldPath);
NodeContainerUI removed = PROJECTS.remove(oldKey);
if (removed == null) {
throw new IllegalArgumentException("No project registered on URI " + oldPath);
}
Set<Object> clientList = WORKFLOW_CLIENTS.remove(oldKey);
WF_LISTENER.workflowChanged(new WorkflowEvent(WorkflowEvent.Type.NODE_REMOVED, removed.getID(), Wrapper.unwrapNC(removed), null));
putWorkflowUI(newPath, nc);
if (clientList != null) {
WORKFLOW_CLIENTS.put(new MapWFKey(newPath), clientList);
}
WF_LISTENER.workflowChanged(new WorkflowEvent(WorkflowEvent.Type.NODE_ADDED, nc.getID(), null, nc));
NSC_LISTENER.stateChanged(new NodeStateEvent(nc.getID()));
}
Aggregations