use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class DisableParallelizationAction method calculateEnabled.
@Override
protected boolean calculateEnabled() {
List parts = getSelectedObjects();
if (parts.isEmpty()) {
return false;
}
if (parts.size() == 1) {
Object o = parts.get(0);
if (o instanceof SubjobContainerPart) {
SubjobContainerPart part = (SubjobContainerPart) o;
SubjobContainer subjob = (SubjobContainer) part.getModel();
Node subStartNode = subjob.getSubjobStartNode();
if (subjob.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
if (subjob.isDisplayed() && ParallelExecutionUtils.isExistPartitioningCon(subStartNode)) {
return true;
} else {
return false;
}
} else {
return false;
}
} else if (o instanceof NodePart) {
NodePart part = (NodePart) o;
Node node = (Node) part.getModel();
if (node.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
if (node.isStart() && ParallelExecutionUtils.isExistPartitioningCon(node)) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
return false;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class DisplaySubjobAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
List editparts = getSelectedObjects();
if (editparts.size() == 1) {
Object o = editparts.get(0);
if (o instanceof NodePart) {
NodePart part = (NodePart) o;
Node node = (Node) part.getModel();
if (node.getJobletNode() != null) {
node = (Node) node.getJobletNode();
}
DisplaySubjobCommand displaySubjobCommand = new DisplaySubjobCommand(node.getNodeContainer().getSubjobContainer());
execute(displaySubjobCommand);
} else if (o instanceof SubjobContainerPart) {
SubjobContainerPart part = (SubjobContainerPart) o;
SubjobContainer subjob = (SubjobContainer) part.getModel();
DisplaySubjobCommand displaySubjobCommand = new DisplaySubjobCommand(subjob);
execute(displaySubjobCommand);
}
}
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ParallelExecutionAction method getCurrentNode.
protected Node getCurrentNode() {
List parts = getSelectedObjects();
if (parts.size() != 1) {
return null;
}
Object o = parts.get(0);
if (o instanceof NodePart) {
NodePart nodePart = (NodePart) o;
node = (Node) nodePart.getModel();
return node;
}
return null;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tesb-studio-se by Talend.
the class OpenTalendJobRefAction method run.
/* Will send a "open" request to the selected nodePart, so it will try to open the reference job.
* If the "open" command success, then will try to switch the perspective to Integration.
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
//diable switch perspective suggestion dialog. just for defense.
String notAskAutoSwitchToDIKey = "notAskAutoSwitchToDI";
boolean oldValueNotSwitchToDiKey = PlatformUI.getPreferenceStore().getBoolean(notAskAutoSwitchToDIKey);
PlatformUI.getPreferenceStore().setValue(notAskAutoSwitchToDIKey, true);
//need to be restore at the end .
// open in editor, type and count already checked in calculateEnabled()
List<?> selectedObjects = getSelectedObjects();
Object select = selectedObjects.get(0);
NodePart nodePart = (NodePart) select;
nodePart.performRequest(new org.eclipse.gef.Request(REQUEST_TYPE_OPEN_NODE_PART));
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (activePage == null) {
return;
}
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor == null || activeEditor.getEditorSite() == null) {
return;
}
Node node = (Node) nodePart.getModel();
String selectedJobName = (String) node.getElementParameter(NODE_PARAM_SELECTED_JOB_NAME).getValue();
String openJobName = activeEditor.getEditorInput().getName();
if (!selectedJobName.equals(openJobName)) {
return;
}
// open/switch editor success and then try to switch perspective.
try {
//if current perspective is ORG_TALEND_RCP_INTEGRATION_PERSPECTIVE, will do nothing in under layer.
PlatformUI.getWorkbench().showPerspective(ORG_TALEND_RCP_INTEGRATION_PERSPECTIVE, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
} catch (WorkbenchException e) {
e.printStackTrace();
} finally {
//Restore config of switch perspective suggestion dialog. just for defense.
PlatformUI.getPreferenceStore().setValue(notAskAutoSwitchToDIKey, oldValueNotSwitchToDiKey);
}
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tesb-studio-se by Talend.
the class OpenTalendJobRefAction method calculateEnabled.
/* Check if this action enable. Will ensure the cTalendJob was selected and has legal value.
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*
*/
@Override
protected boolean calculateEnabled() {
List<?> selectedObjects = getSelectedObjects();
if (selectedObjects.size() != 1) {
//not select one object.
return false;
}
Object select = selectedObjects.get(0);
if (!(select instanceof NodePart)) {
//not select a node.
return false;
}
NodePart nodePart = (NodePart) select;
Node node = (Node) nodePart.getModel();
if (!(node.getComponent() instanceof EmfComponent)) {
//not select a component.
return false;
}
EmfComponent component = (EmfComponent) node.getComponent();
if (!C_TALEND_JOB_COMPONENT_NAME.equals(component.getName())) {
//not cTalendJob component.
return false;
}
Boolean isRepositoryJob = (Boolean) node.getElementParameter(NODE_PARAM_FROM_REPOSITORY_JOB).getValue();
if (isRepositoryJob == null || !isRepositoryJob) {
//not from repository job.
return false;
}
String selectedJobName = (String) node.getElementParameter(NODE_PARAM_SELECTED_JOB_NAME).getValue();
if (selectedJobName == null || selectedJobName.equals("")) {
//no reference job been choice.
return false;
}
return true;
}
Aggregations