use of org.talend.core.model.process.ISubjobContainer in project tdi-studio-se by Talend.
the class AbstractTalendEditor method initializeGraphicalViewer.
// ------------------------------------------------------------------------
// Abstract methods from GraphicalEditor
@Override
protected void initializeGraphicalViewer() {
super.initializeGraphicalViewer();
// this uses the PartFactory set in configureGraphicalViewer
// to create an EditPart for the diagram and sets it as the
// content for the viewer
IProcess2 process = getProcess();
getGraphicalViewer().setContents(process);
// containers are not correctly updated by default, so update them after all nodes have been added
if (process != null) {
for (ISubjobContainer subjobContainer : process.getSubjobContainers()) {
subjobContainer.updateSubjobContainer();
}
}
getGraphicalViewer().getControl().addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
updateActions(getSelectionActions());
}
});
talendEditorDropTargetListener = new TalendEditorDropTargetListener(this);
getGraphicalViewer().addDropTargetListener(talendEditorDropTargetListener);
}
use of org.talend.core.model.process.ISubjobContainer 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.core.model.process.ISubjobContainer in project tdi-studio-se by Talend.
the class JobletUtil method getConnSubjob.
public List<SubjobContainer> getConnSubjob(SubjobContainer sub, List<ISubjobContainer> proSubList) {
List<SubjobContainer> subList = new ArrayList<SubjobContainer>();
if (!proSubList.contains(sub)) {
return subList;
}
for (NodeContainer container : sub.getNodeContainers()) {
List<IConnection> inList = new ArrayList<IConnection>();
List<IConnection> outList = new ArrayList<IConnection>();
if ((container instanceof AbstractJobletContainer)) {
// && ((JobletContainer) container).isCollapsed()
inList.addAll(((JobletContainer) container).getInputs());
outList.addAll(((JobletContainer) container).getOutputs());
} else {
inList.addAll(container.getNode().getIncomingConnections());
outList.addAll(container.getNode().getOutgoingConnections());
}
for (IConnection conn : inList) {
INode source = conn.getSource();
if (source instanceof Node) {
SubjobContainer tem = ((Node) conn.getSource()).getNodeContainer().getSubjobContainer();
if (tem != null && sub != tem) {
if (subList.contains(tem) || !proSubList.contains(tem)) {
continue;
}
subList.add(tem);
proSubList.remove(tem);
subList.addAll(getConnSubjob(tem, proSubList));
}
}
}
for (IConnection conn : outList) {
INode target = conn.getTarget();
if (target instanceof Node) {
SubjobContainer tem = ((Node) conn.getTarget()).getNodeContainer().getSubjobContainer();
if (tem != null && sub != tem) {
if (subList.contains(tem) || !proSubList.contains(tem)) {
continue;
}
subList.add(tem);
proSubList.remove(tem);
subList.addAll(getConnSubjob(tem, proSubList));
}
}
}
}
return subList;
}
use of org.talend.core.model.process.ISubjobContainer in project tdi-studio-se by Talend.
the class ToggleSubjobsAction method run.
@Override
public void run() {
boolean display = isChecked();
getGlobalStore().setValue(TalendDesignerPrefConstants.DISPLAY_SUBJOBS, display);
IEditorReference[] editorParts = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
for (IEditorReference reference : editorParts) {
if (!(reference.getId().equals(MultiPageTalendEditor.ID) || reference.getId().equals(JOBLET_ID) || MAP_REDUCE_MULTIPAGE_EDITOR_ID.equals(reference.getId()) || TEST_CASE_DI_EDITOR.equals(reference.getId()))) {
continue;
}
IEditorPart editorPart = reference.getEditor(false);
if (editorPart == null) {
continue;
}
if (editorPart instanceof AbstractMultiPageTalendEditor) {
AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) editorPart;
IProcess2 process = editor.getTalendEditor().getProcess();
if (process == null) {
continue;
}
List<? extends ISubjobContainer> subjobs = process.getSubjobContainers();
for (ISubjobContainer subjobContainer : subjobs) {
subjobContainer.updateSubjobDisplay();
}
}
}
}
use of org.talend.core.model.process.ISubjobContainer in project tdi-studio-se by Talend.
the class ProcessComposite method refreshSubjobContainer.
/*
* This method is used to clean the Spark Streaming statistics.
*/
public void refreshSubjobContainer() {
org.talend.core.model.process.IProcess2 process = processContext.getProcess();
List<? extends ISubjobContainer> subjobContainers = process.getSubjobContainers();
for (ISubjobContainer subjobContainer : subjobContainers) {
if (subjobContainer instanceof SparkStreamingSubjobContainer) {
((SparkStreamingSubjobContainer) subjobContainer).updateState("UPDATE_SPARKSTREAMING_STATUS", null, 0, 0, "", "", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"");
}
}
}
Aggregations