use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart in project tdi-studio-se by Talend.
the class NodeContainerLayoutEditPolicy method createChangeConstraintCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
@Override
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
if (child instanceof NodeLabelEditPart) {
boolean nodeSelected;
// if (((NodeLabelEditPart) child).getNodePart().getSelected() != 0) {
// nodeSelected = true;
// } else {
nodeSelected = false;
// }
MoveNodeLabelCommand locationCommand = new MoveNodeLabelCommand((NodeLabel) child.getModel(), ((Rectangle) constraint).getLocation(), nodeSelected);
return locationCommand;
} else if (child instanceof NodePart) {
if (((Node) child.getModel()).isReadOnly() && !((Node) child.getModel()).isForceReadOnly()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
} else {
return null;
}
}
use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart in project tdi-studio-se by Talend.
the class TalendSelectionManager method appendSelection.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.SelectionManager#appendSelection(org.eclipse.gef.EditPart)
*/
@Override
public void appendSelection(EditPart arg0) {
// judge whether the refresh operation is executed.
// see bug 3315.
boolean needRefresh = false;
if (getSelection() instanceof StructuredSelection) {
StructuredSelection selection = (StructuredSelection) getSelection();
Object selected = null;
for (Object element : selection.toArray()) {
selected = element;
}
if (getSelection().isEmpty() || (selected instanceof ProcessPart)) {
this.selectionType = ETalendSelectionType.SINGLE;
needRefresh = true;
}
if (!(arg0 instanceof NodeLabelEditPart) && !(arg0 instanceof ConnLabelEditPart) && !(arg0 instanceof ConnectionPart)) {
// removes old selections of labels by calling setSelection
for (Object element : selection.toArray()) {
if (element instanceof NodeLabelEditPart) {
this.deselect(((AbstractGraphicalEditPart) element));
} else if (element instanceof ConnLabelEditPart) {
this.deselect(((AbstractGraphicalEditPart) element));
} else if (element instanceof ConnectionPart) {
this.deselect(((AbstractConnectionEditPart) element));
}
}
needRefresh = true;
}
if (arg0 instanceof ConnectionPerformanceEditPart && getSelectPoint() != null) {
if (needRefresh) {
EditPart transferPart = transferFocus((ConnectionPerformanceEditPart) arg0);
if (transferPart == null) {
needRefresh = false;
setSelectPoint(null);
return;
}
super.appendSelection(transferPart);
needRefresh = false;
return;
}
}
if (needRefresh) {
super.appendSelection(arg0);
needRefresh = false;
setSelectPoint(null);
}
}
}
use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method getSelectedGraphicNode.
/**
* DOC amaumont Comment method "getSelectedNode".
*
* @return
*/
public Node getSelectedGraphicNode() {
Node node = null;
List selections = designerEditor.getViewer().getSelectedEditParts();
if (selections.size() == 1) {
Object selection = selections.get(0);
if (selection instanceof NodeTreeEditPart) {
NodeTreeEditPart nTreePart = (NodeTreeEditPart) selection;
node = (Node) nTreePart.getModel();
} else {
if (selection instanceof NodePart) {
NodePart editPart = (NodePart) selection;
node = (Node) editPart.getModel();
} else if (selection instanceof NodeLabelEditPart) {
NodeLabelEditPart editPart = (NodeLabelEditPart) selection;
node = ((NodeLabel) editPart.getModel()).getNode();
}
}
}
return node;
}
use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart 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.nodes.NodeLabelEditPart 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;
}
}
Aggregations