use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ConnectionCreateAction method getConnectors.
public List<INodeConnector> getConnectors() {
List<INodeConnector> list = new ArrayList<INodeConnector>();
if (getSelectedObjects().isEmpty()) {
return list;
}
List parts = getSelectedObjects();
if (parts.size() == 1) {
Object o = parts.get(0);
if (!(o instanceof NodePart)) {
return list;
}
nodePart = (NodePart) o;
if (!(nodePart.getModel() instanceof Node)) {
return list;
}
Node node = (Node) nodePart.getModel();
if (!node.isActivate()) {
return list;
}
List<INodeConnector> nodeConnectorList = new ArrayList<INodeConnector>(node.getConnectorsFromType(connecType));
List<INodeConnector> toRemove = new ArrayList<INodeConnector>();
for (INodeConnector connector : nodeConnectorList) {
if ((connector.getMaxLinkOutput() != -1) && (connector.getCurLinkNbOutput() >= connector.getMaxLinkOutput())) {
toRemove.add(connector);
} else {
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
if (service.isJobletComponent(node) && !service.isBuiltTriggerConnector(node, connector)) {
toRemove.add(connector);
}
// for bug 10973
List<? extends IConnection> outgoingConnections = node.getOutgoingConnections();
if (service.isTriggerInputNode(node) && outgoingConnections != null && outgoingConnections.size() >= 1) {
toRemove.add(connector);
}
}
}
}
}
nodeConnectorList.removeAll(toRemove);
return nodeConnectorList;
}
return list;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ComponentChooseDialog method setselecte.
private void setselecte(AbstractEditPart part, String lastUniqname) {
List<NodePart> parts = getAllNodePart(part);
for (NodePart nodePart : parts) {
if (nodePart.getModel() instanceof Node) {
Node node = (Node) nodePart.getModel();
// for (String uniqname : uniquteNames) {
if (node.getUniqueName().equals(lastUniqname)) {
nodePart.setDrop(true);
nodePart.setSelected(EditPart.SELECTED);
nodePart.setDrop(false);
} else {
nodePart.setSelected(EditPart.SELECTED_NONE);
}
// }
}
}
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tesb-studio-se by Talend.
the class OpenTalendJobRefAction method run.
/* Will send a "open" request to the selected nodePart, so it will try to open the reference job.
* If the "open" command success, then will try to switch the perspective to Integration.
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
//diable switch perspective suggestion dialog. just for defense.
String notAskAutoSwitchToDIKey = "notAskAutoSwitchToDI";
boolean oldValueNotSwitchToDiKey = PlatformUI.getPreferenceStore().getBoolean(notAskAutoSwitchToDIKey);
PlatformUI.getPreferenceStore().setValue(notAskAutoSwitchToDIKey, true);
//need to be restore at the end .
// open in editor, type and count already checked in calculateEnabled()
List<?> selectedObjects = getSelectedObjects();
Object select = selectedObjects.get(0);
NodePart nodePart = (NodePart) select;
nodePart.performRequest(new org.eclipse.gef.Request(REQUEST_TYPE_OPEN_NODE_PART));
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (activePage == null) {
return;
}
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor == null || activeEditor.getEditorSite() == null) {
return;
}
Node node = (Node) nodePart.getModel();
String selectedJobName = (String) node.getElementParameter(NODE_PARAM_SELECTED_JOB_NAME).getValue();
String openJobName = activeEditor.getEditorInput().getName();
if (!selectedJobName.equals(openJobName)) {
return;
}
// open/switch editor success and then try to switch perspective.
try {
//if current perspective is ORG_TALEND_RCP_INTEGRATION_PERSPECTIVE, will do nothing in under layer.
PlatformUI.getWorkbench().showPerspective(ORG_TALEND_RCP_INTEGRATION_PERSPECTIVE, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
} catch (WorkbenchException e) {
e.printStackTrace();
} finally {
//Restore config of switch perspective suggestion dialog. just for defense.
PlatformUI.getPreferenceStore().setValue(notAskAutoSwitchToDIKey, oldValueNotSwitchToDiKey);
}
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tesb-studio-se by Talend.
the class OpenTalendJobRefAction method calculateEnabled.
/* Check if this action enable. Will ensure the cTalendJob was selected and has legal value.
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*
*/
@Override
protected boolean calculateEnabled() {
List<?> selectedObjects = getSelectedObjects();
if (selectedObjects.size() != 1) {
//not select one object.
return false;
}
Object select = selectedObjects.get(0);
if (!(select instanceof NodePart)) {
//not select a node.
return false;
}
NodePart nodePart = (NodePart) select;
Node node = (Node) nodePart.getModel();
if (!(node.getComponent() instanceof EmfComponent)) {
//not select a component.
return false;
}
EmfComponent component = (EmfComponent) node.getComponent();
if (!C_TALEND_JOB_COMPONENT_NAME.equals(component.getName())) {
//not cTalendJob component.
return false;
}
Boolean isRepositoryJob = (Boolean) node.getElementParameter(NODE_PARAM_FROM_REPOSITORY_JOB).getValue();
if (isRepositoryJob == null || !isRepositoryJob) {
//not from repository job.
return false;
}
String selectedJobName = (String) node.getElementParameter(NODE_PARAM_SELECTED_JOB_NAME).getValue();
if (selectedJobName == null || selectedJobName.equals("")) {
//no reference job been choice.
return false;
}
return true;
}
Aggregations