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;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart 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.NodePart in project tdi-studio-se by Talend.
the class JobletUtil method cloneNode.
public Node cloneNode(Node node, IProcess process, Map<String, List<? extends IElementParameter>> paraMap, boolean lockByOther) {
NodePart nodePart = new NodePart();
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
boolean isInOut = false;
if (service != null) {
isInOut = service.isJobletInOutComponent(node);
}
Node cloneNode = new Node(node.getComponent(), (IProcess2) process, node.getUniqueName());
nodePart.setModel(cloneNode);
if (lockByOther) {
cloneNode.setReadOnly(true);
} else {
cloneNode.setReadOnly(false);
}
cloneNode.setDummy(node.isDummy());
cloneNode.setActivate(node.isActivate());
List<? extends IElementParameter> elementParas = null;
if (paraMap.containsKey(node.getUniqueName())) {
elementParas = paraMap.get(node.getUniqueName());
} else {
elementParas = node.getElementParameters();
}
for (IElementParameter elementPara : elementParas) {
if (elementPara.getName() != null && !elementPara.getName().equals("UNIQUE_NAME")) {
IElementParameter cloneElement = cloneNode.getElementParameter(elementPara.getName());
Object paValue = elementPara.getValue();
if (paValue instanceof List) {
List list = new ArrayList();
list.addAll((List) paValue);
cloneElement.setValue(list);
} else {
// TDI-25599
cloneElement.setContextMode(elementPara.isContextMode());
cloneElement.setValue(elementPara.getValue());
}
if (lockByOther) {
cloneElement.setReadOnly(true);
} else {
cloneElement.setReadOnly(elementPara.isReadOnly());
}
if (elementPara.getChildParameters() != null) {
Map<String, IElementParameter> elementParaChild = elementPara.getChildParameters();
Map<String, IElementParameter> cloneElementChild = cloneElement.getChildParameters();
Iterator<Entry<String, IElementParameter>> ite = elementParaChild.entrySet().iterator();
while (ite.hasNext()) {
Entry<String, IElementParameter> entry = ite.next();
String key = entry.getKey();
IElementParameter c = entry.getValue();
if (key != null && c != null) {
IElementParameter cloneC = cloneElementChild.get(key);
if (cloneC != null) {
cloneC.setValue(c.getValue());
if (lockByOther) {
cloneC.setReadOnly(true);
} else {
cloneC.setReadOnly(c.isReadOnly());
}
}
}
}
}
}
}
for (IElementParameter param : cloneNode.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
if (param.isShow(cloneNode.getElementParameters()) && (repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && param.getFieldType() != EParameterFieldType.MEMO_SQL) {
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
}
}
cloneNode.setMetadataList(node.getMetadataList());
cloneNode.setListConnector(node.getListConnector());
cloneNode.setConnectionName(node.getConnectionName());
cloneNode.setLocation(node.getLocation());
IExternalNode externalNode = cloneNode.getExternalNode();
if (externalNode != null) {
if (node.getExternalData() != null) {
try {
externalNode.setExternalData(node.getExternalData().clone());
} catch (CloneNotSupportedException e) {
ExceptionHandler.process(e);
}
cloneNode.setExternalData(externalNode.getExternalData());
}
if (node.getExternalNode().getExternalEmfData() != null) {
externalNode.setExternalEmfData(EcoreUtil.copy(node.getExternalNode().getExternalEmfData()));
}
// when copy a external node, should also copy screeshot
if (node.getExternalNode() != null) {
ImageDescriptor screenshot = node.getExternalNode().getScreenshot();
if (screenshot != null) {
externalNode.setScreenshot(screenshot);
}
}
}
if (node.getElementParameter(EParameterName.LABEL.getName()) != null) {
cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getElementParameter(EParameterName.LABEL.getName()).getValue());
} else {
cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getLabel());
}
boolean found = false;
for (INode inode : process.getGraphicalNodes()) {
if (inode.getUniqueName().equals(cloneNode.getUniqueName())) {
found = true;
}
}
if (!found) {
((IProcess2) process).removeUniqueNodeName(cloneNode.getUniqueName());
}
return cloneNode;
}
Aggregations