use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.
the class AbstractTraceAction method run.
@Override
public void run() {
List selection = getSelectedObjects();
Object input = selection.get(0);
if (input instanceof ConnectionPart) {
ConnectionPart connPart = (ConnectionPart) input;
List childParts = connPart.getChildren();
for (Object part : childParts) {
if (part != null && part instanceof ConnectionTraceEditPart) {
ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) part;
Connection conn = (Connection) connPart.getModel();
execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
tracePart.refresh();
break;
}
}
}
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) {
ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) part;
Connection conn = (Connection) connPart.getModel();
execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
tracePart.refresh();
break;
}
}
}
if (input instanceof ConnectionTraceEditPart) {
ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) input;
ConnectionPart connPart = (ConnectionPart) tracePart.getParent();
Connection conn = (Connection) connPart.getModel();
execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
tracePart.refresh();
}
}
use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.
the class ActivateElementAction method canPerformAction.
/**
* Test if the selected item is a node.
*
* @return true / false
*/
private boolean canPerformAction() {
if (getSelectedObjects().isEmpty()) {
return false;
}
List parts = getSelectedObjects();
if (parts.size() >= 1) {
Object o = parts.get(0);
nodeList = new ArrayList<Node>();
for (int i = 0; i < parts.size(); i++) {
if (parts.get(i) instanceof NodePart) {
Node node = ((Node) ((NodePart) parts.get(i)).getModel());
if ((!node.isReadOnly()) && (node.getPropertyValue(EParameterName.ACTIVATE.getName()) != null)) {
nodeList.add(node);
}
}
}
connectionList = new ArrayList<Connection>();
for (int i = 0; i < parts.size(); i++) {
if (parts.get(i) instanceof ConnectionPart) {
Connection connection = ((Connection) ((ConnectionPart) parts.get(i)).getModel());
if (!connection.isReadOnly() && connection.getSource().isActivate() && connection.getTarget().isActivate()) {
connectionList.add(connection);
}
}
if (parts.get(i) instanceof ConnLabelEditPart) {
Connection connection = ((ConnectionLabel) ((ConnLabelEditPart) parts.get(i)).getModel()).getConnection();
if (!connection.isReadOnly() && connection.getSource().isActivate() && connection.getTarget().isActivate()) {
connectionList.add(connection);
}
}
}
if ((nodeList.size() == 0) && (connectionList.size() == 0)) {
return false;
}
for (Node node : nodeList) {
if (node.getJobletNode() != null) {
return false;
}
}
for (Connection conn : connectionList) {
if (conn.getTarget().getJobletNode() != null && conn.getSource().getJobletNode() != null) {
return false;
}
}
if (nodeList.size() != 0) {
if (nodeList.get(0).isActivate()) {
if (nodeList.size() == 1) {
//$NON-NLS-1$
setText(TEXT_REM_ACTIVATE + " " + nodeList.get(0).getLabel());
} else {
setText(TEXT_REM_ACTIVATE);
}
} else {
if (nodeList.size() == 1) {
//$NON-NLS-1$
setText(TEXT_SET_ACTIVATE + " " + nodeList.get(0).getLabel());
} else {
setText(TEXT_SET_ACTIVATE);
}
activate = true;
}
} else {
// connections only
if (connectionList.get(0).isActivate()) {
if (connectionList.size() == 1) {
//$NON-NLS-1$
setText(TEXT_REM_ACTIVATE + " " + connectionList.get(0).getName());
} else {
setText(TEXT_REM_ACTIVATE);
}
} else {
if (connectionList.size() == 1) {
//$NON-NLS-1$
setText(TEXT_SET_ACTIVATE + " " + connectionList.get(0).getName());
} else {
setText(TEXT_SET_ACTIVATE);
}
activate = true;
}
}
return true;
}
return false;
}
use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.
the class GefEditorLabelProvider method getImage.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object objects) {
Node node = null;
if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
return null;
}
if (!(objects instanceof IStructuredSelection)) {
return null;
}
final boolean[] multiple = { false };
Object object = getObject(objects, multiple);
if (object == null) {
return null;
}
if ((object instanceof NodeTreeEditPart)) {
node = (Node) ((NodeTreeEditPart) object).getModel();
} else {
if (object instanceof NodeReturnsTreeEditPart) {
node = lastNode;
} else {
if (object instanceof ProcessPart) {
return ImageProvider.getImage(ECoreImage.PROCESS_ICON);
}
if (object instanceof ConnectionPart) {
return ImageProvider.getImage(EImage.RIGHT_ICON);
}
if (object instanceof NoteEditPart) {
return ImageProvider.getImage(ECoreImage.CODE_ICON);
}
if (object instanceof ConnLabelEditPart) {
return ImageProvider.getImage(EImage.RIGHT_ICON);
}
if ((object instanceof NodeLabelEditPart)) {
node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
}
if (!(object instanceof NodePart)) {
return null;
}
if (node == null) {
node = (Node) ((NodePart) object).getModel();
}
}
}
if (lastNode != node) {
lastNode = node;
}
return CoreImageProvider.getComponentIcon(node.getComponent(), ICON_SIZE.ICON_24);
}
use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.
the class GefEditorLabelProvider method getText.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
public String getText(Object objects) {
Node node = null;
if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
//$NON-NLS-1$
return "No items selected";
}
if (!(objects instanceof IStructuredSelection)) {
return null;
}
final boolean[] multiple = { false };
Object object = getObject(objects, multiple);
if (object == null) /* || ((IStructuredSelection) objects).size() > 1 */
{
//$NON-NLS-1$
return "No items selected";
} else {
if (object instanceof NodeContainerPart) {
NodeContainerPart nContainer = (NodeContainerPart) object;
Process process = (Process) nContainer.getParent().getModel();
return process.getName();
} else if (object instanceof ProcessPart) {
Process process = (Process) ((ProcessPart) object).getModel();
return process.getLabel();
} else if (object instanceof ProcessTreeEditPart) {
Process process = (Process) ((ProcessTreeEditPart) object).getModel();
return process.getName();
}
if (object instanceof ConnectionPart) {
Connection conn = (Connection) ((ConnectionPart) object).getModel();
return conn.getName();
}
if (object instanceof NoteEditPart) {
return Note.class.getSimpleName();
}
if (object instanceof ConnLabelEditPart) {
Connection conn = (Connection) ((ConnectionLabel) ((ConnLabelEditPart) object).getModel()).getConnection();
return conn.getName();
}
if (object instanceof NodeTreeEditPart) {
node = (Node) ((NodeTreeEditPart) object).getModel();
} else {
if (object instanceof NodeReturnsTreeEditPart) {
node = lastNode;
} else {
if (object instanceof NodeLabelEditPart) {
node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
}
if (!(object instanceof NodePart)) {
return null;
}
if (node == null) {
node = (Node) ((NodePart) object).getModel();
}
}
}
if (lastNode != node) {
lastNode = node;
}
String name = node.getUniqueName();
// }
return name;
}
}
use of org.talend.designer.core.ui.editor.connections.ConnLabelEditPart in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationAssist method highlightOveredConnection.
private void highlightOveredConnection(org.eclipse.swt.graphics.Point cursorRelativePosition) {
if (overedConnection != null) {
overedConnection.setLineWidth(1);
overedConnection = null;
}
EditPart findObjectAt = graphicViewer.findObjectAt(new Point(cursorRelativePosition.x, cursorRelativePosition.y));
if (findObjectAt instanceof ConnectionPart) {
overedConnection = (ConnectionFigure) ((ConnectionPart) findObjectAt).getFigure();
} else if (findObjectAt instanceof ConnLabelEditPart) {
overedConnection = (ConnectionFigure) ((ConnectionPart) ((ConnLabelEditPart) findObjectAt).getParent()).getFigure();
}
if (overedConnection != null) {
overedConnection.setLineWidth(2);
}
}
Aggregations