use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class ComponentSettingsView method setPropertiesViewerTitle.
/**
* yzhang Comment method "setPropertiesViewerTitle".
*
* @param elem
*/
private void setPropertiesViewerTitle(Element elem) {
String label = null;
Image image = null;
if (elem instanceof Node) {
label = ((Node) elem).getLabel();
String uniqueName = ((Node) elem).getUniqueName();
if (!label.equals(uniqueName)) {
//$NON-NLS-1$ //$NON-NLS-2$
label = label + "(" + uniqueName + ")";
}
image = CoreImageProvider.getComponentIcon(((Node) elem).getComponent(), ICON_SIZE.ICON_24);
} else if (elem instanceof Connection) {
label = ((Connection) elem).getElementName();
image = ImageProvider.getImage(EImage.RIGHT_ICON);
} else if (elem instanceof Note) {
//$NON-NLS-1$
label = Messages.getString("ComponentSettingsView.note");
image = ImageProvider.getImage(EImage.PASTE_ICON);
} else if (elem instanceof SubjobContainer) {
//$NON-NLS-1$
label = Messages.getString("ComponentSettingsView.subjob");
image = ImageProvider.getImage(EImage.PASTE_ICON);
} else if (elem instanceof ConnectionLabel) {
label = ((ConnectionLabel) elem).getConnection().getElementName();
image = ImageProvider.getImage(EImage.RIGHT_ICON);
}
tabFactory.setTitle(label, image);
super.setTitleToolTip(label);
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class NodePart method propertyChange.
// ------------------------------------------------------------------------
// Abstract methods from PropertyChangeListener
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
public void propertyChange(final PropertyChangeEvent changeEvent) {
boolean needUpdateSubjob = false;
if (!this.isActive()) {
return;
}
if (changeEvent.getPropertyName().equals(Node.LOCATION)) {
refreshVisuals();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.PERFORMANCE_DATA)) {
refreshVisuals();
getParent().refresh();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.INPUTS)) {
refreshTargetConnections();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.OUTPUTS)) {
refreshSourceConnections();
refreshTargetConnections();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.SIZE)) {
refreshVisuals();
getParent().refresh();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.ICON_CHANGE)) {
changeIcon((Node) changeEvent.getSource());
refreshVisuals();
} else if (changeEvent.getPropertyName().equals(EParameterName.ACTIVATE.getName())) {
if (((INode) getModel()).isActivate()) {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(-1);
((NodeFigure) figure).repaint();
refreshVisuals();
} else {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
((NodeFigure) figure).repaint();
refreshVisuals();
}
} else if (changeEvent.getPropertyName().equals(EParameterName.DUMMY.getName())) {
if (((INode) getModel()).isActivate()) {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(-1);
} else {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
}
((NodeFigure) figure).repaint();
refreshVisuals();
} else if (changeEvent.getPropertyName().equals(EParameterName.START.getName())) {
if (((INode) getModel()).isStart()) {
((NodeFigure) figure).setStart(true);
((NodeFigure) figure).repaint();
refreshVisuals();
} else {
((NodeFigure) figure).setStart(false);
((NodeFigure) figure).repaint();
refreshVisuals();
}
} else if (changeEvent.getPropertyName().equals(EParameterName.HINT.getName())) {
if (((Node) getModel()).isSetShowHint()) {
((NodeFigure) figure).setHint(((Node) getModel()).getShowHintText());
} else {
//$NON-NLS-1$
((NodeFigure) figure).setHint("");
}
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(EParameterName.CONNECTION_FORMAT.getName())) {
Node node = (Node) getModel();
for (IConnection conn : ((Node) getModel()).getOutgoingConnections()) {
String connIdName = null;
String oldName = conn.getUniqueName();
if (conn instanceof Connection && conn.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
node.getProcess().removeUniqueConnectionName(oldName);
if (node.getProcess().checkValidConnectionName(node.getConnectionName(), false)) {
connIdName = node.getProcess().generateUniqueConnectionName(node.getConnectionName());
} else {
//$NON-NLS-1$
connIdName = node.getProcess().generateUniqueConnectionName("row");
}
if (node.getProcess().checkValidConnectionName(connIdName)) {
((Connection) conn).setUniqueName(connIdName);
node.getProcess().addUniqueConnectionName(connIdName);
((Connection) conn).setName(connIdName);
} else {
node.getProcess().addUniqueConnectionName(oldName);
}
}
}
} else if (changeEvent.getPropertyName().equals(EParameterName.REPAINT.getName())) {
((NodeFigure) figure).repaint();
refreshVisuals();
EditPart parentPart = getParent();
if (parentPart != null) {
parentPart.refresh();
}
needUpdateSubjob = true;
}
if (needUpdateSubjob) {
EditPart editPart = getParent();
if (editPart != null) {
while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
editPart = editPart.getParent();
}
if (editPart instanceof SubjobContainerPart) {
editPart.refresh();
}
}
}
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class NodePart method getSourceConnectionAnchor.
// ------------------------------------------------------------------------
// Abstract methods from NodeEditPart
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
*/
@Override
public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart connection) {
// return new ChopboxAnchor(getFigure());
if (connection.getModel() instanceof Connection) {
if (((Connection) connection.getModel()).getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
((NodeFigure) getFigure()).addSourceConnection((ConnectionFigure) connection.getFigure());
}
}
Connection conn = (Connection) connection.getModel();
NodeAnchor anchor = new NodeAnchor((NodeFigure) getFigure(), (IGraphicalNode) conn.getSource(), (IGraphicalNode) conn.getTarget(), false);
anchor.setConnection(conn);
return anchor;
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class NodePart method getTargetConnectionAnchor.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
*/
@Override
public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart connection) {
if (connection.getModel() instanceof Connection) {
if (((Connection) connection.getModel()).getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
((NodeFigure) getFigure()).setTargetConnection((ConnectionFigure) connection.getFigure());
}
}
Connection conn = (Connection) connection.getModel();
sourceAnchor = null;
NodeAnchor anchor = new NodeAnchor((NodeFigure) getFigure(), (IGraphicalNode) conn.getSource(), (IGraphicalNode) conn.getTarget(), true);
anchor.setConnection(conn);
return anchor;
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class ConnectionSetAsMainRef method calculateEnabled.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean calculateEnabled() {
if (getSelectedObjects().isEmpty()) {
return false;
}
List parts = getSelectedObjects();
if (parts.size() == 1) {
Object o = parts.get(0);
/*
* if (!(o instanceof ConnectionPart) && !(o instanceof ConnLabelEditPart)) { return false; }
*/
ConnectionPart part = null;
if (o instanceof ConnectionPart) {
part = (ConnectionPart) o;
} else {
if (o instanceof ConnLabelEditPart) {
part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
} else {
return false;
}
}
if (!(part.getModel() instanceof Connection)) {
return false;
}
connection = (Connection) part.getModel();
if (!connection.isActivate()) {
return false;
}
if (connection.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
int nbTargetFlowIn = 0;
INode node = connection.getTarget();
for (IConnection currentConnec : node.getIncomingConnections()) {
if (currentConnec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || currentConnec.getLineStyle().equals(EConnectionType.FLOW_REF)) {
nbTargetFlowIn++;
}
}
if (nbTargetFlowIn <= 1) {
return false;
}
setText(TEXT_SET_REF);
} else {
if (connection.getLineStyle().equals(EConnectionType.FLOW_REF)) {
setText(TEXT_SET_MAIN);
} else {
return false;
}
}
return true;
}
return false;
}
Aggregations