use of org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart 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.subjobcontainer.SubjobContainerPart in project tdi-studio-se by Talend.
the class NodePartKeyHander method navigateTo.
@Override
protected void navigateTo(EditPart part, KeyEvent event) {
// PTODO need be removed
SubjobContainerPart subPart = null;
NoteEditPart noPart = null;
boolean displayVa = true;
if (part instanceof SubjobContainerPart) {
// NodeContainerPart
SubjobContainerPart focusPart = (SubjobContainerPart) part;
List subList = focusPart.getParent().getChildren();
for (int j = 0; j < subList.size(); j++) {
if (subList.get(j) instanceof SubjobContainerPart) {
subPart = (SubjobContainerPart) subList.get(j);
SubjobContainer subContainer = (SubjobContainer) subPart.getModel();
if (subContainer.isDisplayed() == false) {
displayVa = false;
}
} else if (subList.get(j) instanceof NoteEditPart) {
displayVa = false;
}
}
if (displayVa == false) {
part = (EditPart) part.getChildren().get(0);
if (part != null) {
// NodePart
part = (EditPart) part.getChildren().get(0);
}
if (part == null) {
return;
}
}
}
super.navigateTo(part, event);
}
use of org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart in project tdi-studio-se by Talend.
the class NodePart method propertyChange.
// ------------------------------------------------------------------------
// Abstract methods from PropertyChangeListener
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
public void propertyChange(final PropertyChangeEvent changeEvent) {
boolean needUpdateSubjob = false;
if (!this.isActive()) {
return;
}
if (changeEvent.getPropertyName().equals(Node.LOCATION)) {
refreshVisuals();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.PERFORMANCE_DATA)) {
refreshVisuals();
getParent().refresh();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.INPUTS)) {
refreshTargetConnections();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.OUTPUTS)) {
refreshSourceConnections();
refreshTargetConnections();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.SIZE)) {
refreshVisuals();
getParent().refresh();
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(Node.ICON_CHANGE)) {
changeIcon((Node) changeEvent.getSource());
refreshVisuals();
} else if (changeEvent.getPropertyName().equals(EParameterName.ACTIVATE.getName())) {
if (((INode) getModel()).isActivate()) {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(-1);
((NodeFigure) figure).repaint();
refreshVisuals();
} else {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
((NodeFigure) figure).repaint();
refreshVisuals();
}
} else if (changeEvent.getPropertyName().equals(EParameterName.DUMMY.getName())) {
if (((INode) getModel()).isActivate()) {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(-1);
} else {
((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
}
((NodeFigure) figure).repaint();
refreshVisuals();
} else if (changeEvent.getPropertyName().equals(EParameterName.START.getName())) {
if (((INode) getModel()).isStart()) {
((NodeFigure) figure).setStart(true);
((NodeFigure) figure).repaint();
refreshVisuals();
} else {
((NodeFigure) figure).setStart(false);
((NodeFigure) figure).repaint();
refreshVisuals();
}
} else if (changeEvent.getPropertyName().equals(EParameterName.HINT.getName())) {
if (((Node) getModel()).isSetShowHint()) {
((NodeFigure) figure).setHint(((Node) getModel()).getShowHintText());
} else {
//$NON-NLS-1$
((NodeFigure) figure).setHint("");
}
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals(EParameterName.CONNECTION_FORMAT.getName())) {
Node node = (Node) getModel();
for (IConnection conn : ((Node) getModel()).getOutgoingConnections()) {
String connIdName = null;
String oldName = conn.getUniqueName();
if (conn instanceof Connection && conn.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
node.getProcess().removeUniqueConnectionName(oldName);
if (node.getProcess().checkValidConnectionName(node.getConnectionName(), false)) {
connIdName = node.getProcess().generateUniqueConnectionName(node.getConnectionName());
} else {
//$NON-NLS-1$
connIdName = node.getProcess().generateUniqueConnectionName("row");
}
if (node.getProcess().checkValidConnectionName(connIdName)) {
((Connection) conn).setUniqueName(connIdName);
node.getProcess().addUniqueConnectionName(connIdName);
((Connection) conn).setName(connIdName);
} else {
node.getProcess().addUniqueConnectionName(oldName);
}
}
}
} else if (changeEvent.getPropertyName().equals(EParameterName.REPAINT.getName())) {
((NodeFigure) figure).repaint();
refreshVisuals();
EditPart parentPart = getParent();
if (parentPart != null) {
parentPart.refresh();
}
needUpdateSubjob = true;
}
if (needUpdateSubjob) {
EditPart editPart = getParent();
if (editPart != null) {
while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
editPart = editPart.getParent();
}
if (editPart instanceof SubjobContainerPart) {
editPart.refresh();
}
}
}
}
use of org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart in project tdi-studio-se by Talend.
the class NodeProgressBarPart method propertyChange.
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(final PropertyChangeEvent evt) {
String request = evt.getPropertyName();
Double extent = new Double(0);
if (evt.getNewValue() instanceof Double) {
extent = (Double) evt.getNewValue();
}
if (request.equals("UPDATE_STATUS")) {
//$NON-NLS-1$
NodeProgressBarFigure figure = (NodeProgressBarFigure) this.getFigure();
Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
// figure.updateVisible(true);
figure.setProgressData(extent);
((NodeProgressBar) getModel()).setProgressSize((figure).getSize());
refreshVisuals();
}
if (request.equals(NodeProgressBar.LOCATION)) {
//$NON-NLS-1$
refreshVisuals();
getParent().refresh();
}
if (request.equals(EParameterName.ACTIVATE.getName())) {
if (((NodeProgressBar) getModel()).isActivate()) {
((NodeProgressBarFigure) figure).setAlpha(-1);
((NodeProgressBarFigure) figure).repaint();
refreshVisuals();
} else {
((NodeProgressBarFigure) figure).setAlpha(Node.ALPHA_VALUE);
((NodeProgressBarFigure) figure).repaint();
refreshVisuals();
}
}
EditPart editPart = getParent();
if (editPart != null) {
while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
editPart = editPart.getParent();
}
if (editPart instanceof SubjobContainerPart) {
editPart.refresh();
}
}
}
use of org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart in project tdi-studio-se by Talend.
the class ComponentChooseDialog method dragOver.
@Override
public void dragOver(DropTargetEvent event) {
// multi-drag for job,context, sqlPattern.
IStructuredSelection selection = getSelection();
if (selection.size() > 1) {
boolean allowed = true;
Item temItem = null;
Iterator iter = selection.iterator();
while (iter.hasNext()) {
Object next = iter.next();
if (next instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) next;
IRepositoryViewObject object = sourceNode.getObject();
if (object != null) {
Item selectItem = object.getProperty().getItem();
if (temItem == null) {
temItem = selectItem;
continue;
}
if (selectItem instanceof ProcessItem && !(temItem instanceof ProcessItem)) {
allowed = false;
} else if (selectItem instanceof ContextItem && !(temItem instanceof ContextItem)) {
allowed = false;
} else if (selectItem instanceof SQLPatternItem && !(temItem instanceof SQLPatternItem)) {
allowed = false;
}
}
}
}
if (!allowed) {
event.detail = DND.DROP_NONE;
}
} else {
CreateRequest req = ((CreateRequest) getTargetRequest());
Object o = null;
try {
o = req.getNewObject();
} catch (Exception e) {
return;
}
if (!(o instanceof Node)) {
return;
}
RootEditPart rep = editor.getViewer().getRootEditPart().getRoot();
Point viewOriginalPosition = new Point();
if (rep instanceof ScalableFreeformRootEditPart) {
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
Viewport viewport = (Viewport) root.getFigure();
viewOriginalPosition = viewport.getViewLocation();
}
org.eclipse.swt.graphics.Point swtLocation = new org.eclipse.swt.graphics.Point(event.x + viewOriginalPosition.x, event.y + viewOriginalPosition.y);
Canvas canvas = (Canvas) editor.getViewer().getControl();
swtLocation = canvas.toControl(swtLocation);
// System.out.println("topLeft:" + topLeftpoint + " / event:" + swtLocation);
org.eclipse.draw2d.geometry.Point draw2dPosition = new org.eclipse.draw2d.geometry.Point(swtLocation.x, swtLocation.y);
double zoom = 1.0;
if (editor.getViewer().getRootEditPart() instanceof TalendScalableFreeformRootEditPart) {
ZoomManager zoomManager = ((TalendScalableFreeformRootEditPart) editor.getViewer().getRootEditPart()).getZoomManager();
zoom = zoomManager.getZoom();
}
List<ConnectionPart> connectionParts = CreateComponentOnLinkHelper.getConnectionParts(editor.getProcessPart(), draw2dPosition, (Node) o);
double minDistance = 1000000000;
for (ConnectionPart part : connectionParts) {
if (part.getFigure() instanceof PolylineConnection) {
PolylineConnection connection = (PolylineConnection) part.getFigure();
double distance = CreateComponentOnLinkHelper.getDistanceOrthogonal(draw2dPosition.x, draw2dPosition.y, connection, zoom);
if (distance < minDistance) {
selectedConnectionPart = part;
minDistance = Math.min(distance, minDistance);
}
}
}
if (selectedConnectionPart != null && minDistance < 15) {
for (Object child : editor.getProcessPart().getChildren()) {
if (child instanceof SubjobContainerPart) {
CreateComponentOnLinkHelper.unselectAllConnections((SubjobContainerPart) child);
}
}
CreateComponentOnLinkHelper.selectConnection(selectedConnectionPart);
} else {
if (selectedConnectionPart != null) {
CreateComponentOnLinkHelper.unselectConnection(selectedConnectionPart);
}
selectedConnectionPart = null;
}
}
}
Aggregations