use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class NodeContainerEditPart method refreshBounds.
/**
* Adjusts the height and width of the node's figure. It automatically sets them to the preferred height/width of
* the figure (which might change if the warning icons change). It doesn't change x/y position of the figure. It
* does change width and height.
*/
private void refreshBounds() {
NodeUIInformation uiInfo = getNodeContainer().getUIInformation();
int[] bounds = uiInfo.getBounds();
WorkflowRootEditPart parent = (WorkflowRootEditPart) getParent();
NodeContainerFigure fig = (NodeContainerFigure) getFigure();
Dimension pref = fig.getPreferredSize();
boolean set = false;
if (pref.width != bounds[2]) {
bounds[2] = pref.width;
set = true;
}
if (pref.height != bounds[3]) {
bounds[3] = pref.height;
set = true;
}
if (set) {
// notify uiInfo listeners (e.g. node annotations)
m_uiListenerActive = false;
getNodeContainer().setUIInformation(NodeUIInformation.builder().setNodeLocation(bounds[0], bounds[1], bounds[2], bounds[3]).build());
m_uiListenerActive = true;
}
// since ver2.3.0 all coordinates are relative to the icon
Point offset = fig.getOffsetToRefPoint(uiInfo);
bounds[0] -= offset.x;
bounds[1] -= offset.y;
Rectangle rect = new Rectangle(bounds[0], bounds[1], bounds[2], bounds[3]);
fig.setBounds(rect);
parent.setLayoutConstraint(this, fig, rect);
}
use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class WorkflowInPortBarEditPart method createFigure.
/**
* {@inheritDoc}
*/
@Override
protected IFigure createFigure() {
NodeUIInformation uiInfo = ((WorkflowPortBar) getModel()).getUIInfo();
if (uiInfo != null) {
int[] bounds = uiInfo.getBounds();
Rectangle newBounds = new Rectangle(bounds[0], bounds[1], bounds[2], bounds[3]);
return new WorkflowInPortBarFigure(newBounds);
} else {
return new WorkflowInPortBarFigure(getMinMaxXcoordInWorkflow()[0]);
}
}
use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class WorkflowRootEditPart method getModelChildren.
/**
* Returns the model chidlren, that is, the <code>NodeConatiner</code>s that
* are stored in the workflow manager.
*
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
protected List getModelChildren() {
List modelChildren = new ArrayList();
WorkflowManagerUI wfm = getWorkflowManager();
// Add them first so they appear behind everything else
for (Annotation anno : wfm.getWorkflowAnnotations()) {
modelChildren.add(anno);
}
// workflow annotations so they appear above them)
for (NodeAnnotation nodeAnno : wfm.getNodeAnnotations()) {
modelChildren.add(nodeAnno);
}
modelChildren.addAll(wfm.getNodeContainers());
if (wfm.getNrWorkflowIncomingPorts() > 0) {
if (m_inBar == null) {
m_inBar = new WorkflowPortBar(wfm, true);
NodeUIInformation uiInfo = wfm.getInPortsBarUIInfo();
if (uiInfo != null) {
m_inBar.setUIInfo(wfm.getInPortsBarUIInfo());
}
}
modelChildren.add(m_inBar);
}
if (wfm.getNrWorkflowOutgoingPorts() > 0) {
if (m_outBar == null) {
m_outBar = new WorkflowPortBar(wfm, false);
NodeUIInformation uiInfo = wfm.getOutPortsBarUIInfo();
if (uiInfo != null) {
m_outBar.setUIInfo(wfm.getOutPortsBarUIInfo());
}
}
modelChildren.add(m_outBar);
}
return modelChildren;
}
use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class NodeContainerEditPart method activate.
/**
* {@inheritDoc}
*/
@Override
public void activate() {
super.activate();
initFigure();
// If we already have extra info, init figure now
NodeContainerUI cont = getNodeContainer();
NodeUIInformation uiInfo = cont.getUIInformation();
if (uiInfo != null) {
// takes over all info except the coordinates
updateFigureFromUIinfo(uiInfo);
} else {
// set a new empty UI info
NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(0, 0, -1, -1).build();
// not yet a listener -- no event received
cont.setUIInformation(info);
}
// need to notify node annotation about our presence
// the annotation is a child that's added first (placed in background)
// to the viewer - so it doesn't know about the correct location yet
NodeAnnotation nodeAnnotation = cont.getNodeAnnotation();
NodeAnnotationEditPart nodeAnnotationEditPart = (NodeAnnotationEditPart) getViewer().getEditPartRegistry().get(nodeAnnotation);
if (nodeAnnotationEditPart != null) {
nodeAnnotationEditPart.nodeUIInformationChanged(null);
}
IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
store.addPropertyChangeListener(this);
// listen to node container (= model object)
cont.addNodeStateChangeListener(this);
cont.addNodeMessageListener(this);
cont.addProgressListener(this);
cont.addUIInformationListener(this);
cont.addNodePropertyChangedListener(this);
addEditPartListener(this);
updateJobManagerIcon();
checkMetaNodeTemplateIcon();
checkMetaNodeLockIcon();
checkNodeLockIcon();
// set the active (or disabled) state
((NodeContainerFigure) getFigure()).setStateFromNC(cont);
// set the node message
updateNodeMessage();
callHideNodeName();
}
use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class ChangeNodeBoundsCommand method execute.
/**
* Sets the new bounds.
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
if (!Arrays.equals(m_oldBounds, m_newBounds)) {
WorkflowManager wm = getHostWFM();
NodeUIInformation information = NodeUIInformation.builder().setNodeLocation(m_newBounds[0], m_newBounds[1], m_newBounds[2], m_newBounds[3]).build();
NodeContainer container = wm.getNodeContainer(m_nodeID);
// must set explicitly so that event is fired by container
container.setUIInformation(information);
}
}
Aggregations