use of org.talend.designer.core.model.process.AbstractProcessProvider in project tdi-studio-se by Talend.
the class UpdateJobletNodeCommand method needPropagate.
private boolean needPropagate(Node jobletNode) {
List<IProcess2> openedProcesses = UpdateManagerUtils.getOpenedProcess();
boolean opened = false;
for (IProcess2 process : openedProcesses) {
if (process.getId().equals(jobletNode.getProcess().getId())) {
opened = true;
}
}
if (!opened) {
return false;
}
AbstractProcessProvider jobletProcessProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (jobletProcessProvider != null) {
List<UpdateResult> resultList = jobletProcessProvider.checkJobletNodeSchema(jobletNode.getProcess());
if (resultList.size() <= 0) {
return false;
} else {
return true;
}
}
return false;
}
use of org.talend.designer.core.model.process.AbstractProcessProvider in project tdi-studio-se by Talend.
the class GEFDeleteAction method calculateEnabled.
@Override
protected boolean calculateEnabled() {
objectsToDelete = new ArrayList();
List objects = getSelectedObjects();
objectsToDelete.addAll(objects);
if (objects.isEmpty() || (objects.size() == 1 && objects.get(0) instanceof ProcessPart)) {
return false;
}
if (!(objects.get(0) instanceof EditPart)) {
return false;
}
AbstractTalendEditor editor = (AbstractTalendEditor) this.getWorkbenchPart();
AbstractProcessProvider pProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (pProvider != null) {
Map<JobletContainerPart, List<NodePart>> jobletMap = new HashMap<JobletContainerPart, List<NodePart>>();
boolean nodeInJoblet = false;
boolean allJunitnode = true;
boolean hasNode = false;
int i = 0;
for (Object o : objects) {
if (o instanceof NodePart) {
hasNode = true;
NodePart nodePart = (NodePart) o;
Node no = (Node) ((NodePart) o).getModel();
if (no.getProcess().isReadOnly()) {
return false;
}
if (no.isReadOnly()) {
i++;
}
if (no.getJunitNode() == null) {
allJunitnode = false;
}
if (!pProvider.canDeleteNode(no)) {
return false;
}
boolean isCollapsedNode = false;
if (editor.getProcess().getGraphicalNodes().contains(nodePart.getModel())) {
isCollapsedNode = true;
}
if (!isCollapsedNode && nodePart.getParent() instanceof JobletContainerPart) {
JobletContainerPart jobletContainer = (JobletContainerPart) nodePart.getParent();
List<NodePart> jobletNodeParts = jobletMap.get(jobletContainer);
if (jobletNodeParts == null) {
jobletNodeParts = new ArrayList<NodePart>();
jobletMap.put(jobletContainer, jobletNodeParts);
}
jobletNodeParts.add(nodePart);
}
} else if (o instanceof ConnectionPart) {
Connection conn = (Connection) ((ConnectionPart) o).getModel();
if (conn.getSource().getProcess().isReadOnly()) {
return false;
}
if (conn.isReadOnly()) {
i++;
}
} else if (o instanceof ConnLabelEditPart) {
ConnectionLabel connLabel = (ConnectionLabel) ((ConnLabelEditPart) o).getModel();
if (connLabel.getConnection().getSource().getProcess().isReadOnly()) {
return false;
}
if (connLabel.getConnection().isReadOnly()) {
i++;
}
} else if (o instanceof NoteEditPart) {
allJunitnode = false;
Note note = (Note) ((NoteEditPart) o).getModel();
if (note.isReadOnly()) {
i++;
}
} else if (o instanceof SubjobContainerPart) {
SubjobContainer subjob = (SubjobContainer) ((SubjobContainerPart) o).getModel();
if (subjob.getProcess().isReadOnly()) {
return false;
}
if (subjob.isReadOnly()) {
i++;
continue;
}
boolean isAllReadonly = true;
boolean subjobAllJunit = true;
for (NodeContainer nc : subjob.getNodeContainers()) {
Node node = nc.getNode();
if (!node.isReadOnly()) {
isAllReadonly = false;
}
if (node.getJunitNode() == null) {
subjobAllJunit = false;
}
}
if (isAllReadonly || subjobAllJunit) {
i++;
}
}
}
for (JobletContainerPart jobletContainer : jobletMap.keySet()) {
boolean copyJobletNode = true;
List<NodePart> list = jobletMap.get(jobletContainer);
for (Object obj : jobletContainer.getChildren()) {
if (obj instanceof NodePart) {
if (!list.contains(obj)) {
copyJobletNode = false;
break;
}
}
}
if (copyJobletNode) {
objectsToDelete.removeAll(list);
PartFactory factory = new PartFactory();
NodePart createEditPart = (NodePart) factory.createEditPart(jobletContainer, ((NodeContainer) jobletContainer.getModel()).getNode());
createEditPart.setParent(jobletContainer);
createEditPart.installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
objectsToDelete.add(createEditPart);
} else {
nodeInJoblet = true;
}
}
if (((nodeInJoblet || allJunitnode) && hasNode) || i == objects.size()) {
return false;
}
}
return true;
}
Aggregations