use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method selectNode.
/**
* DOC bqian Comment method "selectNode".
*
* @param node
*/
@SuppressWarnings("unchecked")
public void selectNode(String nodeName) {
GraphicalViewer viewer = designerEditor.getViewer();
Object object = viewer.getRootEditPart().getChildren().get(0);
if (object instanceof ProcessPart) {
// ProcessPart < SubjobContainerPart < NodeContainerPart < NodePart
for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
if (editPart instanceof SubjobContainerPart) {
SubjobContainerPart subjobPart = (SubjobContainerPart) editPart;
for (EditPart part : (List<EditPart>) subjobPart.getChildren()) {
if (part instanceof NodeContainerPart) {
EditPart nodePart = (EditPart) part.getChildren().get(0);
if (nodePart instanceof NodePart) {
if (((Node) ((NodePart) nodePart).getModel()).getLabel().equals(nodeName)) {
viewer.select(nodePart);
return;
}
}
}
}
}
}
}
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method selectNode.
/**
* DOC bqian Comment method "selectNode".
*
* @param node
*/
public void selectNode(INode node) {
GraphicalViewer viewer = designerEditor.getViewer();
Object object = viewer.getRootEditPart().getChildren().get(0);
if (object instanceof ProcessPart) {
for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
if (editPart instanceof NodePart) {
if (((NodePart) editPart).getModel().equals(node)) {
viewer.select(editPart);
}
}
}
}
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ActivateSubjobAction 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 Node)) {
return false;
}
Node node = (Node) part.getModel();
boolean isCamelNode = ComponentCategory.CATEGORY_4_CAMEL.getName().equals(node.getProcess().getComponentsType());
if (node.getJobletNode() != null) {
return false;
}
if (!node.isStart() && isCamelNode) {
return false;
}
if (node.isReadOnly()) {
return false;
}
if (node.getPropertyValue(EParameterName.ACTIVATE.getName()) == null) {
return false;
}
if (node.isStart()) {
if (node.isActivate()) {
if (isCamelNode) {
setText(Messages.getString("ActivateSubjobAction.DeactivateCompleteRoute"));
} else {
setText(TEXT_REM_ACTIVATE_COMPLETE);
}
} else {
if (isCamelNode) {
setText(Messages.getString("ActivateSubjobAction.ActivateCompleteRoute"));
} else {
setText(TEXT_SET_ACTIVATE_COMPLETE);
}
}
} else {
if (node.isActivate()) {
setText(TEXT_REM_ACTIVATE_PART);
} else {
setText(TEXT_SET_ACTIVATE_PART);
}
}
return true;
}
return false;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ActivateSubjobAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
List editparts = getSelectedObjects();
if (editparts.size() == 1) {
NodePart part = (NodePart) editparts.get(0);
ChangeActivateStatusSubjobCommand changeActivateStatusCommand = new ChangeActivateStatusSubjobCommand((Node) part.getModel(), false);
execute(changeActivateStatusCommand);
}
}
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;
}
Aggregations