use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractTalendEditor method initializeGraphicalViewer.
// ------------------------------------------------------------------------
// Abstract methods from GraphicalEditor
@Override
protected void initializeGraphicalViewer() {
super.initializeGraphicalViewer();
// this uses the PartFactory set in configureGraphicalViewer
// to create an EditPart for the diagram and sets it as the
// content for the viewer
IProcess2 process = getProcess();
getGraphicalViewer().setContents(process);
// containers are not correctly updated by default, so update them after all nodes have been added
if (process != null) {
for (ISubjobContainer subjobContainer : process.getSubjobContainers()) {
subjobContainer.updateSubjobContainer();
}
}
getGraphicalViewer().getControl().addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
updateActions(getSelectionActions());
}
});
talendEditorDropTargetListener = new TalendEditorDropTargetListener(this);
getGraphicalViewer().addDropTargetListener(talendEditorDropTargetListener);
}
use of org.talend.core.model.process.IProcess2 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;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class JobletUtil method openedInJob.
public boolean openedInJob(JobletProcessItem jobletItem, Node currNode) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart[] editors = page.getEditors();
for (IEditorPart editor : editors) {
if (editor instanceof AbstractMultiPageTalendEditor) {
IProcess2 pro = ((AbstractMultiPageTalendEditor) editor).getProcess();
if (currNode != null) {
IProcess2 currPro = (IProcess2) currNode.getProcess();
if (currPro.getId().equals(pro.getId())) {
List<? extends INode> currNodeList = currPro.getGraphicalNodes();
for (INode node : currNodeList) {
if (node == currNode) {
continue;
} else {
if (((Node) node).isJoblet() && jobletItem.getProperty() != null) {
if (jobletItem.getProperty().getId().equals(node.getComponent().getProcess().getId()) && jobletItem.getProperty().getVersion().equals(node.getComponent().getVersion())) {
boolean haveOpened = !((Node) node).getNodeContainer().isCollapsed();
if (haveOpened) {
return true;
}
}
}
}
}
continue;
}
}
List<? extends INode> nodeList = pro.getGraphicalNodes();
for (INode node : nodeList) {
if (((Node) node).isJoblet() && jobletItem.getProperty() != null) {
if (jobletItem.getProperty().getId().equals(node.getComponent().getProcess().getId()) && jobletItem.getProperty().getVersion().equals(node.getComponent().getVersion())) {
boolean haveOpened = !((Node) node).getNodeContainer().isCollapsed();
if (haveOpened) {
return true;
}
}
}
}
}
}
return false;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class IconSelectionController method createCommand.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
*/
public Command createCommand(Button button) {
Object data = button.getData(NAME);
if (data != null) {
if (ICON_SELECTION.equals(data)) {
FileDialog dial = new FileDialog(composite.getShell(), SWT.NONE);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
dial.setFilterExtensions(new String[] { "*.jpg", "*.png", "*.gif" });
String propertyName = (String) button.getData(PARAMETER_NAME);
String file = dial.open();
if (file != null) {
if (!file.equals("")) {
//$NON-NLS-1$
if (!elem.getPropertyValue(propertyName).equals(file)) {
ImageData imageData = new ImageData(file);
if (ImageUtils.checkSize(ImageDescriptor.createFromImageData(imageData), ImageUtils.ICON_SIZE.ICON_32)) {
if (elem instanceof IProcess2) {
refreshIcon(imageData);
return new IconSelectionCommand((IProcess2) elem, ImageDescriptor.createFromImageData(imageData), file);
}
} else {
MessageDialog.openError(composite.getShell(), //$NON-NLS-1$
Messages.getString("IconSelectionController.MessageTitle"), //$NON-NLS-1$
Messages.getString("IconSelectionController.Messages"));
}
}
}
}
} else if (ICON_REVERT.equals(data)) {
if (elem instanceof IProcess2) {
Image defaultIcon = RepositoryLabelProvider.getDefaultJobletImage(((IProcess2) elem).getProperty().getItem());
ImageDescriptor imageData = ImageDescriptor.createFromImage(defaultIcon);
refreshIcon(defaultIcon.getImageData());
return new IconSelectionCommand((IProcess2) elem, imageData, null);
}
}
}
return null;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class UpdateNodeParameterCommand method execute.
@Override
public void execute() {
if (result == null) {
return;
}
Object updateObject = result.getUpdateObject();
if (updateObject == null || (!(updateObject instanceof Node)) || (!(result.getJob() instanceof IProcess))) {
return;
}
// instance of node before might not be good (loaded while check updates needed)
// so get the instance of the node of the current job in this object.
IProcess process = (IProcess) result.getJob();
for (INode node : process.getGraphicalNodes()) {
if (node.getUniqueName().equals(((Node) updateObject).getUniqueName())) {
updateObject = node;
result.setUpdateObject(updateObject);
break;
}
}
IUpdateItemType updateType = result.getUpdateType();
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case NODE_PROPERTY:
updateProperty();
break;
case NODE_SCHEMA:
updateSchema();
break;
case NODE_QUERY:
updateQuery();
break;
case NODE_SAP_FUNCTION:
updateSAPParameters();
break;
case NODE_SAP_IDOC:
updateSAPIDocParameters();
break;
case NODE_VALIDATION_RULE:
updateValidationRule();
break;
default:
return;
}
}
// else { // for extension
Node node = (Node) updateObject;
if (node.getProcess() instanceof IProcess2) {
PropertyChangeCommand pcc = new PropertyChangeCommand(node, EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
boolean executed = false;
if (process instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) process, pcc);
}
}
if (!executed) {
pcc.execute();
}
}
}
Aggregations