use of org.eclipse.gef.EditPart 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.EditPart in project tdi-studio-se by Talend.
the class NodeLabelEditPart method propertyChange.
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(final PropertyChangeEvent evt) {
String request = evt.getPropertyName();
if (request.equals(NodeLabel.OFFSET_CHANGE)) {
//$NON-NLS-1$ //$NON-NLS-2$
refreshVisuals();
getParent().refresh();
}
if (request.equals(NodeLabel.TEXT_CHANGE)) {
refreshVisuals();
// set the new size to update the node container
((NodeLabel) getModel()).setLabelSize(((SimpleHtmlFigure) figure).getPreferredSize());
NodeLabel label = (NodeLabel) getModel();
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISQLBuilderService.class)) {
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
service.updateSqlBuilderDialogTitle(label.getLabelText(), label.getNode().getProcess().getName(), label.getNode().getUniqueName());
}
getParent().refresh();
// refresh the title of component setting view.
ComponentSettingsView viewer = (ComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ComponentSettingsView.ID);
if (viewer != null) {
viewer.updatePropertiesViewerTitle();
}
}
if (request.equals(NodeLabel.LOCATION)) {
//$NON-NLS-1$
refreshVisuals();
getParent().refresh();
}
if (request.equals(EParameterName.ACTIVATE.getName())) {
if (((NodeLabel) getModel()).isActivate()) {
((SimpleHtmlFigure) figure).setAlpha(-1);
((SimpleHtmlFigure) figure).repaint();
refreshVisuals();
} else {
((SimpleHtmlFigure) figure).setAlpha(Node.ALPHA_VALUE);
((SimpleHtmlFigure) 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.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class NodeErrorEditPart method propertyChange.
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(final PropertyChangeEvent evt) {
String request = evt.getPropertyName();
if (request.equals("UPDATE_STATUS")) {
//$NON-NLS-1$
NodeErrorFigure figure = (NodeErrorFigure) this.getFigure();
Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
figure.updateVisible(node.isErrorFlag(), node.getErrorInfo());
((NodeError) getModel()).setErrorSize((figure).getSize());
refreshVisuals();
}
if (request.equals(NodeError.LOCATION)) {
//$NON-NLS-1$
refreshVisuals();
getParent().refresh();
}
if (request.equals(EParameterName.ACTIVATE.getName())) {
if (((NodeError) getModel()).isActivate()) {
((NodeErrorFigure) figure).setAlpha(-1);
((NodeErrorFigure) figure).repaint();
refreshVisuals();
} else {
((NodeErrorFigure) figure).setAlpha(Node.ALPHA_VALUE);
((NodeErrorFigure) 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.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class VarToolBarFigure method moveDown.
@Override
protected void moveDown() {
CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
List selectedEditParts = getTableManager().getGraphicalViewer().getSelectedEditParts();
List<Integer> indexToMove = new ArrayList<Integer>();
EList<VarNode> nodes = parentTable.getNodes();
for (int i = 0; i < selectedEditParts.size(); i++) {
Object obj = selectedEditParts.get(i);
if (obj instanceof VarNodeEditPart) {
VarNode node = (VarNode) ((VarNodeEditPart) obj).getModel();
int indexOf = nodes.indexOf(node);
if (indexOf != -1 && indexOf < nodes.size() - 1) {
indexToMove.add(indexOf);
}
}
}
Collections.sort(indexToMove);
Collections.reverse(indexToMove);
for (int i = 0; i < indexToMove.size(); i++) {
int index = indexToMove.get(i);
VarNode temp = nodes.get(index);
nodes.remove(temp);
nodes.add(index + 1, temp);
}
for (int i = 0; i < indexToMove.size(); i++) {
EditPart part = (EditPart) tablePart.getChildren().get(indexToMove.get(i) + 1);
tablePart.getViewer().appendSelection(part);
}
}
});
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class VarToolBarFigure method moveUp.
@Override
protected void moveUp() {
CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
List selectedEditParts = getTableManager().getGraphicalViewer().getSelectedEditParts();
List<Integer> indexToMove = new ArrayList<Integer>();
EList<VarNode> nodes = parentTable.getNodes();
for (int i = 0; i < selectedEditParts.size(); i++) {
Object obj = selectedEditParts.get(i);
if (obj instanceof VarNodeEditPart) {
VarNode node = (VarNode) ((VarNodeEditPart) obj).getModel();
int indexOf = nodes.indexOf(node);
if (indexOf != -1 && indexOf > 0) {
indexToMove.add(indexOf);
}
}
}
Collections.sort(indexToMove);
for (int i = 0; i < indexToMove.size(); i++) {
int index = indexToMove.get(i);
VarNode temp = nodes.get(index);
nodes.remove(temp);
nodes.add(index - 1, temp);
}
for (int i = 0; i < indexToMove.size(); i++) {
EditPart part = (EditPart) tablePart.getChildren().get(indexToMove.get(i) - 1);
tablePart.getViewer().appendSelection(part);
}
}
});
}
Aggregations