use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.
the class GEFCopyAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
List objects = GEFDeleteAction.filterSameObject(getSelectedObjects());
if (!objects.isEmpty()) {
Clipboard clipboard = Clipboard.getDefault();
org.eclipse.swt.dnd.Clipboard systemClipboard = new org.eclipse.swt.dnd.Clipboard(Display.getCurrent());
boolean noteTextActived = false;
boolean connectionTextActived = false;
boolean nodeLabelActived = false;
Text text = null;
if (objects.size() == 1) {
if (objects.get(0) instanceof NoteEditPart) {
NoteDirectEditManager directEditManager = ((NoteEditPart) objects.get(0)).getDirectEditManager();
if (directEditManager != null && directEditManager.getCellEditor() != null) {
noteTextActived = true;
}
} else if (objects.get(0) instanceof ConnLabelEditPart) {
ConnLabelEditPart connLabelEditPart = (ConnLabelEditPart) objects.get(0);
if (connLabelEditPart.getDirectEditManager() != null && connLabelEditPart.getDirectEditManager().getTextControl() != null) {
connectionTextActived = true;
}
} else if (objects.get(0) instanceof NodeLabelEditPart) {
NodeLabelEditPart nodeLabelEditPart = (NodeLabelEditPart) objects.get(0);
if (nodeLabelEditPart.getDirectEditManager() != null && nodeLabelEditPart.getDirectEditManager().getCellEditor() != null) {
nodeLabelActived = true;
}
}
}
if (noteTextActived) {
text = ((NoteEditPart) objects.get(0)).getDirectEditManager().getTextControl();
clipboard.setContents(text.getSelectionText());
} else if (connectionTextActived) {
text = ((ConnLabelEditPart) objects.get(0)).getDirectEditManager().getTextControl();
clipboard.setContents(text.getSelectionText());
} else if (nodeLabelActived) {
text = (Text) ((NodeLabelEditPart) objects.get(0)).getDirectEditManager().getCellEditor().getControl();
clipboard.setContents(text.getSelectionText());
} else {
clipboard.setContents(objects);
}
if (text != null && !("").equals(text.getSelectionText())) {
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { text.getSelectionText() };
systemClipboard.setContents(data, transfers);
}
}
// Refreshes the pasteAction's enable status.
IWorkbenchPart part = getWorkbenchPart();
if (part instanceof AbstractTalendEditor) {
AbstractTalendEditor talendEditor = (AbstractTalendEditor) part;
IAction action = talendEditor.getActionRegistry().getAction(ActionFactory.PASTE.getId());
action.setEnabled(true);
}
}
use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.
the class NodePartKeyHander method navigateTo.
@Override
protected void navigateTo(EditPart part, KeyEvent event) {
// PTODO need be removed
SubjobContainerPart subPart = null;
NoteEditPart noPart = null;
boolean displayVa = true;
if (part instanceof SubjobContainerPart) {
// NodeContainerPart
SubjobContainerPart focusPart = (SubjobContainerPart) part;
List subList = focusPart.getParent().getChildren();
for (int j = 0; j < subList.size(); j++) {
if (subList.get(j) instanceof SubjobContainerPart) {
subPart = (SubjobContainerPart) subList.get(j);
SubjobContainer subContainer = (SubjobContainer) subPart.getModel();
if (subContainer.isDisplayed() == false) {
displayVa = false;
}
} else if (subList.get(j) instanceof NoteEditPart) {
displayVa = false;
}
}
if (displayVa == false) {
part = (EditPart) part.getChildren().get(0);
if (part != null) {
// NodePart
part = (EditPart) part.getChildren().get(0);
}
if (part == null) {
return;
}
}
}
super.navigateTo(part, event);
}
use of org.talend.designer.core.ui.editor.notes.NoteEditPart 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.NoteEditPart in project tdi-studio-se by Talend.
the class TalendSelectionManager method filterSelection.
private StructuredSelection filterSelection(StructuredSelection selection) {
List newSelection = new ArrayList(selection.toList());
for (Object element : selection.toArray()) {
if (element instanceof SubjobContainerPart) {
// childrens are NodeContainer part
newSelection.remove(element);
List<NodeContainerPart> nodeContainerParts = ((SubjobContainerPart) element).getChildren();
for (NodeContainerPart nodeContainerPart : nodeContainerParts) {
for (Object object : nodeContainerPart.getChildren()) {
if (object instanceof NodePart) {
if (!newSelection.contains(object)) {
newSelection.add(object);
}
}
}
}
} else if (element instanceof NoteEditPart) {
if (!newSelection.contains(element)) {
newSelection.add(element);
}
} else if (!(element instanceof NodePart)) {
newSelection.remove(element);
}
}
StructuredSelection newList = new StructuredSelection(newSelection);
return newList;
}
use of org.talend.designer.core.ui.editor.notes.NoteEditPart 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);
}
}
}
Aggregations