use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class SubjobContainerLayoutEditPolicy method getCreateCommand.
// ------------------------------------------------------------------------
// Abstract methods from LayoutEditPolicy
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
*/
protected Command getCreateCommand(final CreateRequest request) {
if (((SubjobContainer) getHost().getModel()).isReadOnly()) {
return null;
}
Rectangle constraint = (Rectangle) getConstraintFor(request);
Process linkedProcess = (Process) ((SubjobContainer) getHost().getModel()).getProcess();
Command command = null;
if (Note.class.equals(request.getNewObjectType())) {
command = new CreateNoteCommand(linkedProcess, (Note) request.getNewObject(), constraint.getLocation());
} else if (request.getNewObject() instanceof Node) {
Node node = (Node) request.getNewObject();
NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
command = new CreateNodeContainerCommand(linkedProcess, nodeContainer, constraint.getLocation());
}
return command;
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class PartFactory method createEditPart.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
*/
@Override
public EditPart createEditPart(EditPart context, Object model) {
EditPart part = null;
if (model instanceof SubjobContainer) {
part = new SubjobContainerPart();
} else if (model instanceof Process) {
part = new ProcessPart();
} else if (model instanceof Node) {
part = new NodePart();
} else if (model instanceof Connection) {
part = new ConnectionPart();
} else if (model instanceof ConnectionLabel) {
part = new ConnLabelEditPart();
} else if (model instanceof MonitorConnectionLabel) {
part = new MonitorConnectionLabelPart();
} else if (model instanceof ConnectionPerformance) {
part = new ConnectionPerformanceEditPart();
} else if (model instanceof ConnectionTrace) {
part = new ConnectionTraceEditPart();
} else if (model instanceof ConnectionResuming) {
part = new ConnectionResumingEditPart();
} else if (model instanceof NodeLabel) {
part = new NodeLabelEditPart();
} else if (model instanceof NodeContainer) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
if (testContainerService != null) {
part = testContainerService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
if (((NodeContainer) model).getNode().isSparkJoblet()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
ISparkJobletProviderService sparkService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
if (sparkService != null) {
part = (EditPart) sparkService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
} else if (((NodeContainer) model).getNode().isSparkStreamingJoblet()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
ISparkStreamingJobletProviderService sparkService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
if (sparkService != null) {
part = (EditPart) sparkService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
} else if (((NodeContainer) model).getNode().isStandardJoblet()) {
part = new JobletContainerPart();
} else if (((NodeContainer) model).getNode().isMapReduce()) {
part = new JobletContainerPart();
} else {
part = new NodeContainerPart();
}
} else if (model instanceof Note) {
part = new NoteEditPart();
} else if (model instanceof NodeError) {
part = new NodeErrorEditPart();
} else if (model instanceof NodeProgressBar) {
part = new NodeProgressBarPart();
} else {
return null;
}
// tell the newly created part about the model object
part.setModel(model);
return part;
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class NotesPasteCommand method orderNoteParts.
private void orderNoteParts(List<NoteEditPart> noteParts) {
this.noteParts = new ArrayList<NoteEditPart>();
Point curLocation;
NoteEditPart toAdd = null;
List<NoteEditPart> restToOrder = new ArrayList<NoteEditPart>();
restToOrder.addAll(noteParts);
for (NoteEditPart copiedNodePart : noteParts) {
curLocation = null;
for (NoteEditPart partToOrder : restToOrder) {
Note copiedNote = (Note) partToOrder.getModel();
if (curLocation == null) {
curLocation = copiedNote.getLocation();
toAdd = partToOrder;
} else {
if (curLocation.y >= copiedNote.getLocation().y) {
if (curLocation.x >= copiedNote.getLocation().x) {
curLocation = copiedNote.getLocation();
toAdd = partToOrder;
}
}
}
}
if (toAdd != null) {
this.noteParts.add(toAdd);
restToOrder.remove(toAdd);
}
}
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class NotesPasteCommand method findLocationForNoteInProcess.
@SuppressWarnings("unchecked")
private Point findLocationForNoteInProcess(final Point location, Dimension size) {
Rectangle copiedRect = new Rectangle(location.x, location.y, size.width, size.height);
Point newLocation = new Point(location);
for (Note node : process.getNotes()) {
Rectangle currentRect = new Rectangle(node.getLocation().x, node.getLocation().y, node.getSize().width, node.getSize().height);
if (currentRect.intersects(copiedRect)) {
newLocation.x += TalendEditor.GRID_SIZE;
newLocation.y += TalendEditor.GRID_SIZE;
return findLocationForNoteInProcess(newLocation, size);
}
}
return newLocation;
}
use of org.talend.designer.core.ui.editor.notes.Note in project tdi-studio-se by Talend.
the class NotesPasteCommand method execute.
@SuppressWarnings("unchecked")
@Override
public void execute() {
// create the note list to paste
createNoteList();
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
// save old selection
if (!multipleCommand) {
oldSelection = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
oldSelection.add(editPart);
}
// remove the old selection
viewer.deselectAll();
}
// creates the different notes
for (Note note : noteList) {
process.addNote(note);
}
// set the new note as the current selection
if (!multipleCommand) {
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 NoteEditPart) {
Note currentNode = (Note) editPart.getModel();
if (noteList.contains(currentNode)) {
sel.add(editPart);
}
}
}
StructuredSelection s = new StructuredSelection(sel);
viewer.setSelection(s);
}
}
process.checkStartNodes();
process.checkProcess();
}
Aggregations