use of org.eclipse.gef.editparts.AbstractGraphicalEditPart in project tdi-studio-se by Talend.
the class JobletContainerPart method propertyChange.
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
public void propertyChange(PropertyChangeEvent changeEvent) {
String prop = changeEvent.getPropertyName();
boolean needUpdateSubjob = false;
if (prop.equals(EParameterName.HINT.getName())) {
Node node = ((NodeContainer) getModel()).getNode();
// ((JobletContainerFigure) figure).setInfoHint(node.getShowHintText());
} else if (JobletContainer.UPDATE_JOBLET_CONTENT.equals(prop)) {
refresh();
List<AbstractGraphicalEditPart> childrens = getChildren();
for (AbstractGraphicalEditPart part : childrens) {
part.refresh();
}
needUpdateSubjob = true;
} else if (JobletContainer.UPDATE_JOBLET_CONNECTIONS.equals(prop)) {
refreshSourceConnections();
} else if (JobletContainer.UPDATE_JOBLET_TITLE_COLOR.equals(prop)) {
if (getFigure() instanceof JobletContainerFigure) {
((JobletContainerFigure) getFigure()).updateJobletContainerColor();
refreshVisuals();
}
} else if (JobletContainer.UPDATE_JOBLET_DISPLAY.equals(prop)) {
if (getFigure() instanceof JobletContainerFigure) {
((JobletContainerFigure) getFigure()).updateJobletContainerColor();
refreshVisuals();
}
needUpdateSubjob = true;
} else if (changeEvent.getPropertyName().equals("UPDATE_STATUS")) {
// ((JobletContainer) getModel()).updateJobletNodes(true);
if (getFigure() instanceof JobletContainerFigure) {
String newValue = (String) changeEvent.getNewValue();
if (newValue != null && newValue.equals("CLEAR")) {
((JobletContainerFigure) getFigure()).refreshNodes(true);
} else {
((JobletContainerFigure) getFigure()).refreshNodes(false);
}
if (((JobletContainer) getModel()).getNode().isMapReduce()) {
JobletContainer jCon = (JobletContainer) getModel();
if (jCon.getNode().isMapReduceStart()) {
jCon.updateJobletNodes(true);
((JobletContainerFigure) getFigure()).updateData();
} else if (jCon.getMrStartContainer() != null) {
jCon.getMrStartContainer().updateJobletNodes(true);
}
}
}
refreshVisuals();
} else if (changeEvent.getPropertyName().equals("UPDATE_MR_STATUS")) {
if (getFigure() instanceof JobletContainerFigure) {
((JobletContainerFigure) getFigure()).refreshMRstatus();
}
refreshVisuals();
} else {
// can only be UPDATE_SUBJOB_DATA, need to modify if some others are added
if (getFigure() instanceof JobletContainerFigure) {
if (((JobletContainer) getModel()).getNode().isMapReduce()) {
JobletContainer jCon = (JobletContainer) getModel();
if (jCon.getNode().isMapReduceStart()) {
jCon.updateJobletNodes(true);
} else if (jCon.getMrStartContainer() != null) {
jCon.getMrStartContainer().updateJobletNodes(true);
}
}
((JobletContainerFigure) getFigure()).updateData();
refreshVisuals();
}
}
if (changeEvent.getPropertyName().equals(EParameterName.ACTIVATE.getName())) {
Node node = ((NodeContainer) getModel()).getNode();
if (node.isActivate()) {
// ((JobletContainerFigure) figure).setAlpha(-1);
((JobletContainerFigure) figure).repaint();
refreshVisuals();
} else {
// ((JobletContainerFigure) figure).setAlpha(Node.ALPHA_VALUE);
((JobletContainerFigure) figure).repaint();
refreshVisuals();
}
}
if (changeEvent.getPropertyName().equals(Node.PERFORMANCE_DATA)) {
refreshVisuals();
}
if (needUpdateSubjob) {
EditPart editPart = getParent();
if (editPart != null) {
while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
editPart = editPart.getParent();
}
Node node = ((NodeContainer) getModel()).getNode();
List<ISubjobContainer> proSubList = new ArrayList<ISubjobContainer>(((IProcess2) node.getProcess()).getSubjobContainers());
if (editPart instanceof SubjobContainerPart) {
// Node node = ((NodeContainer) getModel()).getNode();
JobletContainer nc = (JobletContainer) this.getModel();
// Rectangle rec = new Rectangle(node.getLocation(), node.getSize());
boolean isCollapse = nc.isCollapsed() && !nc.getNode().isMapReduceStart();
int rightChangewidth = nc.getRightChangeWidth();
int downChangeheight = nc.getDownChangeHeight();
int leftChangewidth = nc.getLeftChangeWidth();
int upChangeheight = nc.getUpChangeHeight();
if (nc.getNode().isJoblet()) {
if (editPart instanceof SubjobContainerPart) {
((SubjobContainer) ((SubjobContainerPart) editPart).getModel()).refreshNodesLocation(isCollapse, nc, rightChangewidth, downChangeheight, leftChangewidth, upChangeheight);
}
// for (ISubjobContainer sb : proSubList) {
// ((SubjobContainer) sb).refreshNodesLocation(isCollapse, nc, rightChangewidth,
// downChangeheight,
// leftChangewidth, upChangeheight);
// }
}
editPart.refresh();
}
}
}
if (changeEvent.getPropertyName().equals(Node.UPDATE_STATUS)) {
Node node = ((NodeContainer) getModel()).getNode();
if (node != null && node.isMapReduce()) {
((JobletContainerFigure) this.getFigure()).updateErrorFlag(node.isErrorFlag());
((JobletContainerFigure) this.getFigure()).setShowCompareMark(node.isCompareFlag() && !node.isErrorFlag());
IElementParameter param = node.getElementParameter(EParameterName.INFORMATION.getName());
if (param != null) {
boolean showInfoFlag = Boolean.TRUE.equals(param.getValue());
if (changeEvent.getNewValue() instanceof Integer) {
Integer status = (Integer) changeEvent.getNewValue();
if (status != null) {
((JobletContainerFigure) this.getFigure()).updateStatus(status, showInfoFlag);
}
((JobletContainerFigure) this.getFigure()).setInfoHint(node.getShowHintText());
}
refreshVisuals();
}
} else {
((JobletContainerFigure) getFigure()).updateStatus(node.getStatus());
}
}
}
use of org.eclipse.gef.editparts.AbstractGraphicalEditPart in project tdi-studio-se by Talend.
the class TalendSelectionManager method appendSelection.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.SelectionManager#appendSelection(org.eclipse.gef.EditPart)
*/
@Override
public void appendSelection(EditPart arg0) {
// judge whether the refresh operation is executed.
// see bug 3315.
boolean needRefresh = false;
if (getSelection() instanceof StructuredSelection) {
StructuredSelection selection = (StructuredSelection) getSelection();
Object selected = null;
for (Object element : selection.toArray()) {
selected = element;
}
if (getSelection().isEmpty() || (selected instanceof ProcessPart)) {
this.selectionType = ETalendSelectionType.SINGLE;
needRefresh = true;
}
if (!(arg0 instanceof NodeLabelEditPart) && !(arg0 instanceof ConnLabelEditPart) && !(arg0 instanceof ConnectionPart)) {
// removes old selections of labels by calling setSelection
for (Object element : selection.toArray()) {
if (element instanceof NodeLabelEditPart) {
this.deselect(((AbstractGraphicalEditPart) element));
} else if (element instanceof ConnLabelEditPart) {
this.deselect(((AbstractGraphicalEditPart) element));
} else if (element instanceof ConnectionPart) {
this.deselect(((AbstractConnectionEditPart) element));
}
}
needRefresh = true;
}
if (arg0 instanceof ConnectionPerformanceEditPart && getSelectPoint() != null) {
if (needRefresh) {
EditPart transferPart = transferFocus((ConnectionPerformanceEditPart) arg0);
if (transferPart == null) {
needRefresh = false;
setSelectPoint(null);
return;
}
super.appendSelection(transferPart);
needRefresh = false;
return;
}
}
if (needRefresh) {
super.appendSelection(arg0);
needRefresh = false;
setSelectPoint(null);
}
}
}
use of org.eclipse.gef.editparts.AbstractGraphicalEditPart in project tdi-studio-se by Talend.
the class XmlDropTargetListener method updateTargetEditPart.
@Override
protected void updateTargetEditPart() {
super.updateTargetEditPart();
Point dropLocation = getDropLocation();
if (getTargetEditPart() != null) {
targetFigure = ((AbstractGraphicalEditPart) getTargetEditPart()).getFigure().findFigureAt(dropLocation.x, dropLocation.y);
}
}
use of org.eclipse.gef.editparts.AbstractGraphicalEditPart in project tdi-studio-se by Talend.
the class DragAndDropEditPolicy method eraseTargetFeedback.
@Override
public void eraseTargetFeedback(Request request) {
if (indicator != null) {
if (request instanceof CreateNodeConnectionRequest) {
CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
if (targetEditPart != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
try {
getFeedbackLayer().remove(indicator);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
}
use of org.eclipse.gef.editparts.AbstractGraphicalEditPart in project tdi-studio-se by Talend.
the class SubjobContainerPart method propertyChange.
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
if (SubjobContainer.UPDATE_SUBJOB_CONTENT.equals(prop)) {
refresh();
List<AbstractGraphicalEditPart> childrens = getChildren();
for (AbstractGraphicalEditPart part : childrens) {
part.refresh();
}
} else if (SubjobContainer.UPDATE_SUBJOB_CONNECTIONS.equals(prop)) {
refreshSourceConnections();
} else if (SubjobContainer.UPDATE_SUBJOB_TITLE_COLOR.equals(prop)) {
if (getFigure() instanceof SubjobContainerFigure) {
((SubjobContainerFigure) getFigure()).updateSubJobTitleColor();
refreshVisuals();
}
} else if (SubjobContainer.UPDATE_SUBJOB_DISPLAY.equals(prop)) {
List<NodeContainer> tmpList = new ArrayList<NodeContainer>(((SubjobContainer) getModel()).getNodeContainers());
((SubjobContainer) getModel()).getNodeContainers().clear();
refreshChildren();
List elems = ((Process) getParent().getModel()).getElements();
elems.remove(getModel());
EditPart parent = getParent();
parent.refresh();
((SubjobContainer) getModel()).getNodeContainers().addAll(tmpList);
elems.add(getModel());
parent.refresh();
} else if ("UPDATE_SPARKSTREAMING_STATUS".equals(prop)) {
if (getFigure() instanceof SparkStreamingSubjobContainerFigure) {
((SparkStreamingSubjobContainerFigure) getFigure()).updateData();
refreshVisuals();
}
} else {
// can only be UPDATE_SUBJOB_DATA, need to modify if some others are added
if (getFigure() instanceof SubjobContainerFigure) {
((SubjobContainerFigure) getFigure()).updateData();
refreshVisuals();
}
}
}
Aggregations