use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.
the class ModifyOutputOrderAction 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) {
return false;
}
Object o = parts.get(0);
EConnectionType tmpConnType = null;
INode node = null;
if (o instanceof ConnectionPart) {
ConnectionPart part = (ConnectionPart) o;
Connection connection = (Connection) part.getModel();
node = connection.getSource();
tmpConnType = connection.getLineStyle();
} else if (o instanceof ConnLabelEditPart) {
ConnectionPart part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
Connection connection = (Connection) part.getModel();
node = connection.getSource();
tmpConnType = connection.getLineStyle();
} else if (o instanceof NodePart) {
node = (Node) ((NodePart) o).getModel();
}
if (node == null) {
return false;
}
usedConnType = false;
//$NON-NLS-1$
String midStr = "output";
int nb = 0;
for (Connection connection : (List<Connection>) node.getOutgoingConnections()) {
if (getConnectionCategory() != null && connection.getLineStyle().hasConnectionCategory(getConnectionCategory())) {
// avoid the not useful action, on connection.
if (tmpConnType == null || tmpConnType != null && tmpConnType.hasConnectionCategory(getConnectionCategory())) {
nb++;
}
} else // feature 4505 & 8087
if (getConnectionType() != null && connection.getLineStyle() == getConnectionType()) {
midStr = getConnectionType().getDefaultLinkName();
usedConnType = true;
// avoid the not useful action, on connection.
if (tmpConnType == null || tmpConnType != null && tmpConnType == getConnectionType()) {
nb++;
}
}
}
if (nb < 2) {
return false;
}
multipleOutputNode = node;
//$NON-NLS-1$
setText(Messages.getString("ModifyOutputOrderAction.text", midStr));
return true;
}
use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.
the class FilterTraceColumnAction method calculateEnabled.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean calculateEnabled() {
List parts = getSelectedObjects();
if (parts.size() != 1) {
return false;
}
Object input = parts.get(0);
if (input instanceof ConnectionPart) {
ConnectionPart connPart = (ConnectionPart) input;
List childParts = connPart.getChildren();
for (Object part : childParts) {
if (part != null && part instanceof ConnectionTraceEditPart) {
connection = (Connection) connPart.getModel();
return connection.enableTraces() && connection.checkTraceShowEnable();
}
}
}
if (input instanceof ConnLabelEditPart) {
ConnLabelEditPart labelPart = (ConnLabelEditPart) input;
ConnectionPart connPart = (ConnectionPart) labelPart.getParent();
List childParts = connPart.getChildren();
for (Object part : childParts) {
if (part != null && part instanceof ConnectionTraceEditPart) {
connection = (Connection) connPart.getModel();
return connection.enableTraces() && connection.checkTraceShowEnable();
}
}
}
if (input instanceof ConnectionTraceEditPart) {
ConnectionTraceEditPart connTrace = (ConnectionTraceEditPart) input;
if (connTrace.getParent() instanceof ConnectionPart) {
ConnectionPart connPart = (ConnectionPart) connTrace.getParent();
connection = (Connection) connPart.getModel();
return connection.enableTraces() && connection.checkTraceShowEnable();
}
}
return false;
}
use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.
the class CreateComponentOnLinkHelper method unselectAllConnections.
public static void unselectAllConnections(SubjobContainerPart containerPart) {
List children = containerPart.getChildren();
for (int i = 0; i < children.size(); i++) {
Object object = children.get(i);
if (object instanceof NodeContainerPart) {
NodeContainerPart nodeContainerPart = (NodeContainerPart) object;
Object nodePart = nodeContainerPart.getChildren().get(0);
if (nodePart instanceof NodePart) {
List sourceConnections = ((NodePart) nodePart).getSourceConnections();
for (int j = 0; j < sourceConnections.size(); j++) {
Object connectionPart = sourceConnections.get(j);
if (connectionPart instanceof ConnectionPart) {
ConnectionPart connPart = (ConnectionPart) connectionPart;
org.talend.designer.core.ui.editor.connections.Connection conn = (org.talend.designer.core.ui.editor.connections.Connection) connPart.getModel();
ConnectionFigure fig = (ConnectionFigure) connPart.getFigure();
if (fig.getLineWidth() != 1) {
fig.setLineWidth(1);
connPart.refresh();
}
}
}
}
}
}
}
use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.
the class CreateComponentOnLinkHelper method getConnectionParts.
public static List<ConnectionPart> getConnectionParts(ProcessPart processPart, Point point, Node node) {
List<ConnectionPart> connectionParts = new ArrayList<ConnectionPart>();
for (Object child : processPart.getChildren()) {
if (child instanceof SubjobContainerPart) {
SubjobContainerPart subJobPart = (SubjobContainerPart) child;
for (Object sChilde : subJobPart.getChildren()) {
if (sChilde instanceof NodeContainerPart) {
NodeContainerPart nodeCPart = (NodeContainerPart) sChilde;
for (Object nChild : nodeCPart.getChildren()) {
if (nChild instanceof NodePart) {
for (Object conn : ((NodePart) nChild).getTargetConnections()) {
if (conn instanceof ConnectionPart && canCreateNodeOnLink((Connection) ((ConnectionPart) conn).getModel(), node)) {
ConnectionPart connPart = (ConnectionPart) conn;
// if (connPart.getFigure() != null &&
// connPart.getFigure().getBounds().contains(point)) {
connectionParts.add((ConnectionPart) conn);
// }
}
}
}
}
}
}
}
}
return connectionParts;
}
use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.
the class CreateComponentOnLinkHelper method selectConnection.
public static void selectConnection(Connection connection, SubjobContainerPart containerPart) {
List children = containerPart.getChildren();
for (int i = 0; i < children.size(); i++) {
Object object = children.get(i);
if (object instanceof NodeContainerPart) {
NodeContainerPart nodeContainerPart = (NodeContainerPart) object;
Object nodePart = nodeContainerPart.getChildren().get(0);
if (nodePart instanceof NodePart) {
List sourceConnections = ((NodePart) nodePart).getSourceConnections();
for (int j = 0; j < sourceConnections.size(); j++) {
Object connectionPart = sourceConnections.get(j);
if (connectionPart instanceof ConnectionPart) {
ConnectionPart connPart = (ConnectionPart) connectionPart;
org.talend.designer.core.ui.editor.connections.Connection conn = (org.talend.designer.core.ui.editor.connections.Connection) connPart.getModel();
if (conn.equals(connection)) {
ConnectionFigure fig = (ConnectionFigure) connPart.getFigure();
if (fig.getLineWidth() != 2) {
fig.setLineWidth(2);
connPart.refresh();
}
} else {
ConnectionFigure fig = (ConnectionFigure) connPart.getFigure();
if (fig.getLineWidth() != 1) {
fig.setLineWidth(1);
connPart.refresh();
}
}
}
}
}
}
}
}
Aggregations