use of org.talend.designer.core.model.components.EmfComponent 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