use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart in project tdi-studio-se by Talend.
the class CreateComponentOnLinkHelper method getConnection.
public static List<Connection> getConnection(SubjobContainerPart containerPart, Point point, Node node) {
List<Connection> connectionList = new ArrayList<Connection>();
List<Connection> connList = new ArrayList<Connection>();
List children = containerPart.getChildren();
for (int i = 0; i < children.size(); i++) {
Object object = children.get(i);
if (object instanceof NodeContainerPart) {
NodeContainerPart nodePart = (NodeContainerPart) object;
Object o = nodePart.getChildren().get(0);
if (o instanceof NodePart) {
List connections = ((NodePart) o).getSourceConnections();
for (int j = 0; j < connections.size(); j++) {
Object connection = connections.get(j);
if (connection instanceof ConnectionPart) {
ConnectionPart connPart = (ConnectionPart) connection;
Connection conn = (Connection) connPart.getModel();
if (canCreateNodeOnLink(conn, node)) {
Rectangle bounds = ((ConnectionPart) connection).getFigure().getBounds();
// System.out.println("location:" + point);
if (bounds.contains(point)) {
// System.out.println("bounds:" + bounds);
connectionList.add(conn);
}
if (containsPoint(bounds, point)) {
// System.out.println("contains");
connList.add(conn);
}
}
}
}
}
}
}
if (!connectionList.isEmpty()) {
return connectionList;
} else {
return connList;
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createValidationRule.
/**
* DOC ycbai Comment method "createValidationRule".
*
* @param dragModel
* @param targetEditPart
*/
private void createValidationRule(Object dragModel, EditPart targetEditPart) {
if (!(dragModel instanceof RepositoryNode && targetEditPart instanceof NodeContainerPart)) {
return;
}
RepositoryNode dragNode = (RepositoryNode) dragModel;
NodeContainerPart nodePart = (NodeContainerPart) targetEditPart;
if (dragNode.getObject().getProperty().getItem() instanceof ValidationRulesConnectionItem) {
Node node = (Node) nodePart.getNodePart().getModel();
List<IRepositoryViewObject> valRuleObjs = ValidationRulesUtil.getRelatedValidationRuleObjs(node);
IRepositoryViewObject valRuleObj = dragNode.getObject();
String schemaType = (String) node.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
if (EmfComponent.BUILTIN.equals(schemaType) || !ValidationRulesUtil.isCurrentValRuleObjInList(valRuleObjs, valRuleObj)) {
MessageDialog.openWarning(editor.getSite().getShell(), //$NON-NLS-1$
Messages.getString("SchemaTypeController.validationrule.title.warn"), //$NON-NLS-1$
Messages.getString("SchemaTypeController.validationrule.cannotApplyValMsg"));
return;
}
CompoundCommand cc = new CompoundCommand();
cc.add(new PropertyChangeCommand(node, EParameterName.VALIDATION_RULES.getName(), true));
cc.add(new //$NON-NLS-1$
ChangeValuesFromRepository(//$NON-NLS-1$
node, //$NON-NLS-1$
null, //$NON-NLS-1$
"VALIDATION_RULE_TYPE:VALIDATION_RULE_TYPE", EmfComponent.REPOSITORY));
cc.add(new PropertyChangeCommand(node, EParameterName.REPOSITORY_VALIDATION_RULE_TYPE.getName(), valRuleObj.getProperty().getId()));
execCommandStack(cc);
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart in project tdi-studio-se by Talend.
the class SetParallelizationAction method run.
@Override
public void run() {
List editparts = getSelectedObjects();
if (editparts.size() == 1) {
Object o = editparts.get(0);
if (o instanceof NodePart) {
NodePart part = (NodePart) o;
Node node = (Node) part.getModel();
getCommandStack().execute(new SetParallelizationCommand(node));
} else if (o instanceof SubjobContainerPart) {
boolean hasStartNode = false;
List<NodeContainerPart> childNodes = ((SubjobContainerPart) o).getChildren();
for (NodeContainerPart childNode : childNodes) {
NodeContainerPart part = (NodeContainerPart) childNode;
NodeContainer node = (NodeContainer) part.getModel();
if (node.getNode().isStart()) {
hasStartNode = true;
getCommandStack().execute(new SetParallelizationCommand(node.getNode()));
}
}
if (!hasStartNode) {
for (NodeContainerPart childNode : childNodes) {
NodeContainerPart part = (NodeContainerPart) childNode;
NodeContainer node = (NodeContainer) part.getModel();
if (node.getNode().isSubProcessStart()) {
getCommandStack().execute(new SetParallelizationCommand(node.getNode()));
}
}
}
}
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart in project tdi-studio-se by Talend.
the class JobletUtil method cloneNodeContainer.
public NodeContainer cloneNodeContainer(NodeContainer nodeContainer, Node cloneNode) {
NodeContainerPart nodeConPart = new NodeContainerPart();
// TDI-13132
IComponent tempComponent = cloneNode.getComponent();
if (tempComponent != null) {
String tempComponentName = tempComponent.getName();
if (tempComponentName != null) {
IComponent component = ComponentsFactoryProvider.getInstance().get(tempComponentName, cloneNode.getProcess().getComponentsType());
if (component != null) {
cloneNode.setComponent(component);
}
}
}
NodeContainer cloneNodeContainer = new NodeContainer(cloneNode);
nodeConPart.setModel(cloneNodeContainer);
cloneNodeContainer.setNodeError(cloneNode.getNodeError());
cloneNodeContainer.setNodeLabel(cloneNode.getNodeLabel());
cloneNodeContainer.setNodeProgressBar(cloneNode.getNodeProgressBar());
cloneNodeContainer.setReadOnly(nodeContainer.isReadOnly());
return cloneNodeContainer;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart in project tdi-studio-se by Talend.
the class GEFDeleteAction method createDeleteCommand.
@Override
public Command createDeleteCommand(List objects) {
objects = filterSameObject(objectsToDelete);
if (objects.isEmpty()) {
return null;
}
if (!(objects.get(0) instanceof EditPart)) {
return null;
}
EditPart object = (EditPart) objects.get(0);
// for TUP-1015
boolean isConnAttachedJLTriggerComp = false;
ConnectionPart connectionPart = null;
if (object instanceof ConnectionPart) {
connectionPart = (ConnectionPart) object;
} else if (object instanceof ConnLabelEditPart) {
connectionPart = (ConnectionPart) object.getParent();
}
if (connectionPart != null) {
Node srcNode = null;
Object srcModel = connectionPart.getSource().getModel();
if (srcModel instanceof Node) {
srcNode = (Node) srcModel;
}
Node tarNode = null;
Object tarModel = connectionPart.getTarget().getModel();
if (tarModel instanceof Node) {
tarNode = (Node) tarModel;
}
if (srcNode == null || tarNode == null) {
return null;
}
IProcess process = srcNode.getProcess();
if (AbstractProcessProvider.isExtensionProcessForJoblet(process)) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && (service.isTriggerNode(srcNode) || service.isTriggerNode(tarNode))) {
isConnAttachedJLTriggerComp = true;
}
}
}
IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
String preKey = TalendDesignerPrefConstants.NOT_SHOW_WARNING_WHEN_DELETE_LINK_WITH_JOBLETTRIGGERLINKCOMPONENT;
if (isConnAttachedJLTriggerComp && !preferenceStore.getBoolean(preKey)) {
MessageDialogWithToggle jlTriggerConfirmDialog = new MessageDialogWithToggle(null, //$NON-NLS-1$
Messages.getString("GEFDeleteAction.deleteConnectionDialog.title"), // accept the default window icon
null, Messages.getString("GEFDeleteAction.deleteConnectionDialog.msg"), MessageDialog.WARNING, new String[] { //$NON-NLS-1$
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, //$NON-NLS-1$
Messages.getString("GEFDeleteAction.deleteConnectionDialog.toggleMsg"), preferenceStore.getDefaultBoolean(preKey));
jlTriggerConfirmDialog.setPrefStore(preferenceStore);
jlTriggerConfirmDialog.setPrefKey(preKey);
if (jlTriggerConfirmDialog.open() != IDialogConstants.YES_ID) {
return null;
}
preferenceStore.setValue(preKey, jlTriggerConfirmDialog.getToggleState());
}
List nodeParts = new ArrayList();
List noteParts = new ArrayList();
List others = new ArrayList(objects);
for (Object o : objects) {
if (o instanceof NodePart) {
others.remove(o);
Node model = (Node) ((NodePart) o).getModel();
if (model.getJobletNode() != null) {
continue;
}
if (model.getJunitNode() != null) {
continue;
}
nodeParts.add(o);
} else if (o instanceof NoteEditPart) {
noteParts.add(o);
others.remove(o);
} else if (o instanceof SubjobContainerPart) {
others.remove(o);
SubjobContainerPart subjob = (SubjobContainerPart) o;
for (Iterator iterator = subjob.getChildren().iterator(); iterator.hasNext(); ) {
NodeContainerPart nodeContainerPart = (NodeContainerPart) iterator.next();
if (nodeContainerPart instanceof JobletContainerPart) {
JobletContainer jobletCon = (JobletContainer) ((JobletContainerPart) nodeContainerPart).getModel();
JobletContainerFigure jobletFigure = (JobletContainerFigure) ((JobletContainerPart) nodeContainerPart).getFigure();
if (!jobletCon.isCollapsed()) {
jobletFigure.doCollapse();
}
}
NodePart nodePart = nodeContainerPart.getNodePart();
if (nodePart != null) {
Node model = (Node) nodePart.getModel();
if (model.getJunitNode() != null) {
continue;
}
nodeParts.add(nodePart);
}
}
}
}
if (others.size() == 0) {
// so notes & nodes only
CompoundCommand cpdCmd = new CompoundCommand();
//$NON-NLS-1$
cpdCmd.setLabel(Messages.getString("GEFDeleteAction.DeleteItems"));
if (nodeParts.size() != 0) {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(nodeParts);
cpdCmd.add(((NodePart) nodeParts.get(0)).getCommand(deleteReq));
}
if (noteParts.size() != 0) {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(noteParts);
cpdCmd.add(((NoteEditPart) noteParts.get(0)).getCommand(deleteReq));
}
return cpdCmd;
} else {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(objects);
Command cmd = object.getCommand(deleteReq);
return cmd;
}
}
Aggregations