use of org.talend.designer.core.ui.editor.process.ProcessPart in project tdi-studio-se by Talend.
the class ShowComponentSettingViewerAction method canPerformAction.
/**
* Test if the selected item is a node.
*
* @return true / false
*/
private boolean canPerformAction() {
if (getSelectedObjects().isEmpty()) {
return false;
}
List parts = getSelectedObjects();
if (parts.size() == 1) {
Object o = parts.get(0);
if (!(o instanceof NodePart)) {
return false;
}
NodePart part = (NodePart) o;
if (!(part.getModel() instanceof INode)) {
return false;
}
node = (Node) part.getModel();
EditPart parentPart = part.getParent();
while (!(parentPart instanceof ProcessPart)) {
parentPart = parentPart.getParent();
}
if (!(parentPart instanceof ProcessPart)) {
return false;
}
process = (IProcess) ((ProcessPart) parentPart).getModel();
//$NON-NLS-1$
setText(Messages.getString("PropertiesContextAction.Properties"));
}
return true;
}
use of org.talend.designer.core.ui.editor.process.ProcessPart 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.talend.designer.core.ui.editor.process.ProcessPart 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.talend.designer.core.ui.editor.process.ProcessPart 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.talend.designer.core.ui.editor.process.ProcessPart in project tdi-studio-se by Talend.
the class OpenJobHierarchyAction method calculateEnabled.
@Override
protected boolean calculateEnabled() {
List parts = getSelectedObjects();
if (parts.size() != 1) {
return false;
}
Object o = parts.get(0);
if (o instanceof NodePart) {
NodePart part = (NodePart) o;
Node node = (Node) part.getModel();
if (DesignerUtilities.isTRunJobComponent(node)) {
return true;
}
} else if (o instanceof ProcessPart) {
return true;
}
return false;
}
Aggregations