use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.
the class MultiplePasteCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.CompoundCommand#execute()
*/
@Override
public void execute() {
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
oldSelection = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
oldSelection.add(editPart);
}
// remove the old selection
viewer.deselectAll();
super.execute();
EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
if (processPart instanceof ProcessPart) {
// can only be ProcessPart but still test
List<EditPart> sel = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
if (editPart instanceof NodePart) {
Node currentNode = (Node) editPart.getModel();
if (nodeCmd.getNodeContainerList().contains(currentNode.getNodeContainer())) {
sel.add(editPart);
}
} else if (editPart instanceof NoteEditPart) {
Note currentNode = (Note) editPart.getModel();
if (noteCmd.getNoteList().contains(currentNode)) {
sel.add(editPart);
}
} else if (editPart instanceof SubjobContainerPart) {
// add for the bug TDI-7706
for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
if (subjobChildsPart instanceof NodeContainerPart) {
if (nodeCmd.getNodeContainerList().contains(((NodeContainerPart) subjobChildsPart).getModel())) {
NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
if (nodePart != null) {
sel.add(nodePart);
}
}
}
}
}
}
StructuredSelection s = new StructuredSelection(sel);
viewer.setSelection(s);
}
}
use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.
the class ZorderAction method calculateEnabled.
@Override
protected boolean calculateEnabled() {
List editparts = getSelectedObjects();
if (editparts.size() == 1) {
if (editparts.get(0) instanceof NoteEditPart || editparts.get(0) instanceof SubjobContainerPart) {
editPart = (EditPart) editparts.get(0);
createZOrderCommand();
return zorderCommand.canExecute();
}
}
return false;
}
use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tesb-studio-se by Talend.
the class RoutePasteAction method run.
@SuppressWarnings("unchecked")
@Override
public void run() {
Object clipBoardContent;
try {
clipBoardContent = Clipboard.getDefault().getContents();
} catch (RuntimeException e) {
return;
}
org.eclipse.swt.dnd.Clipboard systemClipboard = new org.eclipse.swt.dnd.Clipboard(Display.getCurrent());
Object systemObject = systemClipboard.getContents(TextTransfer.getInstance());
if (clipBoardContent instanceof List) {
List<EditPart> partsList = (List<EditPart>) clipBoardContent;
if (partsList == null || partsList.isEmpty()) {
return;
}
List<NodePart> nodeParts = new ArrayList<NodePart>();
List<NoteEditPart> noteParts = new ArrayList<NoteEditPart>();
for (Object o : partsList) {
if (o instanceof NodePart) {
if (!nodeParts.contains(o)) {
nodeParts.add((NodePart) o);
}
} else if (o instanceof NoteEditPart) {
noteParts.add((NoteEditPart) o);
}
}
CamelTalendEditor editor = (CamelTalendEditor) this.getWorkbenchPart();
org.eclipse.draw2d.geometry.Point gefPoint = getCursorLocation();
AbstractProcessProvider findProcessProviderFromPID = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (findProcessProviderFromPID != null) {
boolean isDuplicateRoutelet = false;
String duplicateRouteletName = "";
for (NodePart copiedNodePart : nodeParts) {
Node copiedNode = (Node) copiedNodePart.getModel();
// add for bug TDI-20207.if copy joblet/job to itself,then return.
EComponentType componentType = null;
String copideNodeId = null;
String editorProcessId = null;
if (copiedNode.getComponent() != null) {
componentType = copiedNode.getComponent().getComponentType();
if (copiedNode.getComponent().getProcess() != null) {
copideNodeId = copiedNode.getComponent().getProcess().getId();
}
}
if (editor.getProcess() != null) {
editorProcessId = editor.getProcess().getId();
}
for (IElementParameter element : copiedNode.getElementParametersFromField(EParameterFieldType.PROCESS_TYPE)) {
for (Map.Entry<String, IElementParameter> entry : element.getChildParameters().entrySet()) {
if (("PROCESS_TYPE_PROCESS").equals(entry.getKey())) {
if (editorProcessId != null && editorProcessId.equals(entry.getValue().getValue())) {
return;
}
}
}
}
if ((EComponentType.JOBLET).equals(componentType)) {
// Check if is copying routelet in itself
if (editorProcessId != null && editorProcessId.equals(copideNodeId)) {
return;
}
// Check if is duplicate routelet
if (editor.getProcess().getNodesOfType(copiedNode.getComponent().getName()).size() > 0) {
isDuplicateRoutelet = true;
// $NON-NLS-1$
duplicateRouteletName += " ," + copiedNode.getComponent().getName();
}
}
// Check if it's Camel component
if (!ComponentCategory.CATEGORY_4_CAMEL.getName().equals(copiedNode.getComponent().getType())) {
return;
}
}
if (isDuplicateRoutelet) {
MessageDialog.openInformation(editor.getEditorSite().getShell(), // $NON-NLS-1$
"Copying Routelet", // $NON-NLS-1$
"Do not allow duplicate Routelets\nRoutelet \"" + duplicateRouteletName.substring(2) + "\" already exist.");
return;
}
}
if (nodeParts.size() != 0 && noteParts.size() != 0) {
MultiplePasteCommand mpc = new MultiplePasteCommand(nodeParts, noteParts, (org.talend.designer.core.ui.editor.process.Process) editor.getProcess(), gefPoint);
mpc.setSelectedSubjobs(new ArrayList<SubjobContainerPart>());
execute(mpc);
} else if (nodeParts.size() != 0) {
NodesPasteCommand cmd = new NodesPasteCommand(nodeParts, (org.talend.designer.core.ui.editor.process.Process) editor.getProcess(), gefPoint);
cmd.setSelectedSubjobs(new ArrayList<SubjobContainerPart>());
execute(cmd);
} else if (noteParts.size() != 0) {
NotesPasteCommand cmd = new NotesPasteCommand(noteParts, (org.talend.designer.core.ui.editor.process.Process) editor.getProcess(), gefPoint, false, null);
execute(cmd);
}
setCursorLocation(null);
} else if (clipBoardContent instanceof String) {
List objects = getSelectedObjects();
if (objects.size() == 1) {
String content = (String) clipBoardContent;
if (objects.get(0) instanceof NoteEditPart && ((NoteEditPart) objects.get(0)).getDirectEditManager() != null) {
Text text = ((NoteEditPart) objects.get(0)).getDirectEditManager().getTextControl();
if (text != null) {
text.insert(content);
}
} else if (objects.get(0) instanceof ConnLabelEditPart && ((ConnLabelEditPart) objects.get(0)).getDirectEditManager() != null) {
Text text = ((ConnLabelEditPart) objects.get(0)).getDirectEditManager().getTextControl();
if (text != null) {
text.insert(content);
}
} else if (objects.get(0) instanceof NodeLabelEditPart && ((NodeLabelEditPart) objects.get(0)).getDirectEditManager() != null) {
{
Text text = (Text) ((NodeLabelEditPart) objects.get(0)).getDirectEditManager().getCellEditor().getControl();
if (text != null) {
text.insert(content);
}
}
}
}
} else if (systemObject != null && systemObject instanceof String) {
List objects = getSelectedObjects();
if (objects.size() == 1) {
String content = (String) systemObject;
if (objects.get(0) instanceof NoteEditPart && ((NoteEditPart) objects.get(0)).getDirectEditManager() != null) {
Text text = ((NoteEditPart) objects.get(0)).getDirectEditManager().getTextControl();
if (text != null) {
text.insert(content);
}
} else if (objects.get(0) instanceof ConnLabelEditPart && ((ConnLabelEditPart) objects.get(0)).getDirectEditManager() != null) {
Text text = ((ConnLabelEditPart) objects.get(0)).getDirectEditManager().getTextControl();
if (text != null) {
text.insert(content);
}
} else if (objects.get(0) instanceof NodeLabelEditPart && ((NodeLabelEditPart) objects.get(0)).getDirectEditManager() != null) {
{
Text text = (Text) ((NodeLabelEditPart) objects.get(0)).getDirectEditManager().getCellEditor().getControl();
if (text != null) {
text.insert(content);
}
}
}
}
}
}
use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.
the class ProcessLayoutEditPolicy method createChangeConstraintCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
@Override
public Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
// return a command to move the part to the location given by the constraint
if (child instanceof NodePart) {
if (((Node) child.getModel()).isReadOnly()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof NoteEditPart) {
if (((Note) child.getModel()).isReadOnly()) {
return null;
}
MoveNoteCommand locationCommand = new MoveNoteCommand((Note) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof SubjobContainerPart) {
SubjobContainer sjc = (SubjobContainer) child.getModel();
Point sjcLocation = sjc.getSubjobContainerRectangle().getLocation();
Point translationNeeded = new Point(((Rectangle) constraint).getLocation().x - sjcLocation.x, ((Rectangle) constraint).getLocation().y - sjcLocation.y);
CompoundCommand cc = new CompoundCommand();
for (NodeContainer nc : sjc.getNodeContainers()) {
if (nc.isReadOnly()) {
return null;
}
IGraphicalNode node = nc.getNode();
Point nodeLocation = node.getLocation();
MoveNodeCommand locationCommand = new MoveNodeCommand(nc.getNode(), nodeLocation.getTranslated(translationNeeded));
cc.add(locationCommand);
}
return cc;
}
return null;
}
use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.
the class SubjobContainerLayoutEditPolicy method createAddCommand.
// ------------------------------------------------------------------------
// Abstract methods from ConstrainedLayoutEditPolicy
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createAddCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
protected Command createAddCommand(final EditPart child, final Object constraint) {
if (child instanceof NoteEditPart) {
if (((Note) child.getModel()).isReadOnly()) {
return null;
}
MoveNoteCommand locationCommand = new MoveNoteCommand((Note) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
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()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
} else {
return null;
}
}
Aggregations