use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class NodesPasteCommand method orderNodeParts.
private void orderNodeParts(List<NodePart> nodeParts) {
this.nodeParts = new ArrayList<NodePart>();
Point curLocation;
NodePart toAdd = null;
List<NodePart> restToOrder = new ArrayList<NodePart>();
restToOrder.addAll(nodeParts);
for (NodePart copiedNodePart : nodeParts) {
curLocation = null;
for (NodePart partToOrder : restToOrder) {
IGraphicalNode copiedNode = (IGraphicalNode) partToOrder.getModel();
if (curLocation == null) {
curLocation = copiedNode.getLocation();
toAdd = partToOrder;
} else {
if (curLocation.y >= copiedNode.getLocation().y) {
if (curLocation.x >= copiedNode.getLocation().x) {
curLocation = copiedNode.getLocation();
toAdd = partToOrder;
}
}
}
}
if (toAdd != null) {
this.nodeParts.add(toAdd);
restToOrder.remove(toAdd);
}
}
}
use of org.talend.designer.core.ui.editor.nodes.NodePart 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.nodes.NodePart in project tdi-studio-se by Talend.
the class AbstractTalendEditor method getCommonKeyHandler.
/**
* DOC qzhang Comment method "getCommonKeyHandler".
*
* @return
*/
public KeyHandler getCommonKeyHandler() {
if (sharedKeyHandler == null) {
sharedKeyHandler = new KeyHandler();
sharedKeyHandler.put(KeyStroke.getPressed(SWT.F1, 0), new Action() {
@Override
public void run() {
ISelection selection = getGraphicalViewer().getSelection();
if (selection != null) {
if (selection instanceof IStructuredSelection) {
Object input = ((IStructuredSelection) selection).getFirstElement();
Node node = null;
if (input instanceof NodeTreeEditPart) {
NodeTreeEditPart nTreePart = (NodeTreeEditPart) input;
node = (Node) nTreePart.getModel();
} else {
if (input instanceof NodePart) {
EditPart editPart = (EditPart) input;
node = (Node) editPart.getModel();
}
}
if (node != null) {
String helpLink = (String) node.getPropertyValue(EParameterName.HELP.getName());
String requiredHelpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
if (helpLink == null || "".equals(helpLink) || !requiredHelpLink.equals(helpLink)) {
helpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
}
PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpLink);
}
}
}
}
});
sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));
// deactivate the F2 shortcut as it's not used anymore
// sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
// getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
}
return sharedKeyHandler;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class AbstractTalendEditor method setFocus.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.ui.parts.GraphicalEditor#setFocus()
*/
@Override
public void setFocus() {
IComponentSettingsView viewer = (IComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IComponentSettingsView.ID);
if (viewer != null) {
IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
if (selection.size() == 1 && (selection.getFirstElement() instanceof NodePart || selection.getFirstElement() instanceof ConnectionPart || selection.getFirstElement() instanceof SubjobContainerPart || selection.getFirstElement() instanceof ConnLabelEditPart)) {
viewer.setElement((Element) ((AbstractEditPart) selection.getFirstElement()).getModel());
} else {
viewer.cleanDisplay();
}
}
JobSettings.switchToCurJobSettingsView();
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
testContainerService.switchToCurTestContainerView();
}
}
super.setFocus();
if (!readOnly) {
// When gain focus, check read-only to disable read-only mode if process has been restore while opened :
// 1. Enabled/disabled components :
// process.checkReadOnly();
// 2. Set backgroung color :
List children = getViewer().getRootEditPart().getChildren();
if (!children.isEmpty()) {
ProcessPart rep = (ProcessPart) children.get(0);
rep.ajustReadOnly();
}
}
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ShowComponentSettingViewerAction 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);
if (!(o instanceof NodePart)) {
return false;
}
NodePart part = (NodePart) o;
if (!(part.getModel() instanceof INode)) {
return false;
}
node = (Node) part.getModel();
EditPart parentPart = part.getParent();
while (!(parentPart instanceof ProcessPart)) {
parentPart = parentPart.getParent();
}
if (!(parentPart instanceof ProcessPart)) {
return false;
}
process = (IProcess) ((ProcessPart) parentPart).getModel();
//$NON-NLS-1$
setText(Messages.getString("PropertiesContextAction.Properties"));
}
return true;
}
Aggregations