use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ActivateSubjobOneComponentAction 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 Node)) {
return false;
}
Node node = (Node) part.getModel();
if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(node.getProcess().getComponentsType())) {
return false;
}
if (node.getJobletNode() != null) {
return false;
}
if (node.isReadOnly()) {
return false;
}
if (node.getPropertyValue(EParameterName.ACTIVATE.getName()) == null) {
return false;
}
if (node.isSubProcessStart() && node.isStart()) {
if (node.isActivate()) {
setText(TEXT_REM_ACTIVATE_PART);
} else {
setText(TEXT_SET_ACTIVATE_PART);
}
return true;
} else {
return false;
}
}
return false;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ConnectionCreateAction method canPerformAction.
/**
* Test if the selected item is a node.
*
* @return true/false
*/
@SuppressWarnings("unchecked")
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 = (NodePart) o;
if (!(nodePart.getModel() instanceof Node)) {
return false;
}
Node node = (Node) nodePart.getModel();
if (!node.isActivate()) {
return false;
}
if (node.getJobletNode() != null) {
return false;
}
if (curNodeConnector != null && "VALIDATION_REJECT".equals(curNodeConnector.getName())) {
if (node.getProcess() != null && !ComponentCategory.CATEGORY_4_DI.getName().equals(node.getProcess().getComponentsType())) {
return false;
}
}
if (connecType.hasConnectionCategory(IConnectionCategory.EXECUTION_ORDER)) {
if (!(Boolean) node.getPropertyValue(EParameterName.STARTABLE.getName()) || (!node.getProcessStartNode(false).equals(node))) {
if (!node.isELTMapComponent()) {
boolean jobletOk = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(node)) {
jobletOk = true;
}
}
if (!jobletOk) {
return false;
}
}
}
}
menuList = new ArrayList<String>();
if (curNodeConnector == null) {
curNodeConnector = node.getConnectorFromType(connecType);
if (curNodeConnector == null) {
return false;
}
}
if (curNodeConnector.getMaxLinkOutput() != -1) {
if (curNodeConnector.getCurLinkNbOutput() >= curNodeConnector.getMaxLinkOutput()) {
return false;
}
}
if (curNodeConnector.getMaxLinkOutput() == 0) {
return false;
}
/**
* judge whether to show the table link menu in ELTMap components
*/
if (curNodeConnector.getName().equals(EConnectionType.TABLE.getName())) {
List<? extends IConnection> tableRefs = node.getOutgoingConnections(EConnectionType.TABLE_REF);
if (tableRefs != null && 0 < tableRefs.size()) {
return false;
}
}
if (!curNodeConnector.isMultiSchema()) {
// setText(curNodeConnector.getMenuName());
}
if (curNodeConnector.isMultiSchema()) {
for (int i = 0; i < node.getMetadataList().size(); i++) {
IMetadataTable table = (node.getMetadataList().get(i));
String value = table.getAdditionalProperties().get(ISINPUT);
if (value != null && value.equals(TRUE)) {
continue;
}
String name = table.getTableName();
if (name.equals(node.getUniqueName())) {
continue;
}
if (table.getAttachedConnector() == null || table.getAttachedConnector().equals(curNodeConnector.getName())) {
if (connecType == EConnectionType.TABLE) {
//$NON-NLS-1$ //$NON-NLS-2$
name = table.getLabel() + " (" + name + ")";
}
boolean nameUsed = false;
for (Connection connec : (List<Connection>) node.getOutgoingConnections()) {
if (connec.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
if (connec.getMetadataTable().getTableName().equals(table.getTableName())) {
nameUsed = true;
}
}
}
// if the name is not already in the process adds to the list
if (!nameUsed) {
menuList.add(name);
}
}
}
if ((curNodeConnector.getMaxLinkOutput() == -1 || node.getMetadataList().size() < curNodeConnector.getMaxLinkOutput()) && curNodeConnector.isBuiltIn()) {
menuList.add(getNewOutputMenuName());
}
} else {
String menuName;
boolean addDefaultName = false;
// get linked metadata to connector
IMetadataTable table = null;
for (int i = 0; i < node.getMetadataList().size(); i++) {
table = (node.getMetadataList().get(i));
if (table.getTableName().equals(node.getUniqueName())) {
break;
}
}
// if EBCDIC + single schema mode, only have one output maximum
if (node.getComponent().getName().contains("EBCDIC") && node.checkSchemaForEBCDIC(table) && curNodeConnector.getCurLinkNbOutput() > 0) {
return false;
}
if (connecType == EConnectionType.TABLE) {
addDefaultName = addDefaultName();
menuName = getNewOutputMenuName();
} else {
menuName = curNodeConnector.getMenuName();
}
if (!addDefaultName) {
setText(menuName);
menuList.add(menuName);
}
}
return true;
}
return false;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ModifyMergeOrderAction method calculateEnabled.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean calculateEnabled() {
if (getSelectedObjects().isEmpty()) {
return false;
}
List parts = getSelectedObjects();
if (parts.size() != 1) {
return false;
}
Object o = parts.get(0);
INode node = null;
if (o instanceof ConnectionPart) {
ConnectionPart part = (ConnectionPart) o;
IConnection connection = (IConnection) part.getModel();
node = connection.getTarget();
} else if (o instanceof ConnLabelEditPart) {
ConnectionPart part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
Connection connection = (Connection) part.getModel();
node = connection.getTarget();
} else if (o instanceof NodePart) {
node = (Node) ((NodePart) o).getModel();
}
if ((node == null) || (!node.getComponent().useMerge())) {
return false;
}
mergeComponent = node;
setText(TEXT_MERGE_ORDER);
return true;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class ModifyOutputOrderAction method calculateEnabled.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean calculateEnabled() {
if (getSelectedObjects().isEmpty()) {
return false;
}
List parts = getSelectedObjects();
if (parts.size() != 1) {
return false;
}
Object o = parts.get(0);
EConnectionType tmpConnType = null;
INode node = null;
if (o instanceof ConnectionPart) {
ConnectionPart part = (ConnectionPart) o;
Connection connection = (Connection) part.getModel();
node = connection.getSource();
tmpConnType = connection.getLineStyle();
} else if (o instanceof ConnLabelEditPart) {
ConnectionPart part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
Connection connection = (Connection) part.getModel();
node = connection.getSource();
tmpConnType = connection.getLineStyle();
} else if (o instanceof NodePart) {
node = (Node) ((NodePart) o).getModel();
}
if (node == null) {
return false;
}
usedConnType = false;
//$NON-NLS-1$
String midStr = "output";
int nb = 0;
for (Connection connection : (List<Connection>) node.getOutgoingConnections()) {
if (getConnectionCategory() != null && connection.getLineStyle().hasConnectionCategory(getConnectionCategory())) {
// avoid the not useful action, on connection.
if (tmpConnType == null || tmpConnType != null && tmpConnType.hasConnectionCategory(getConnectionCategory())) {
nb++;
}
} else // feature 4505 & 8087
if (getConnectionType() != null && connection.getLineStyle() == getConnectionType()) {
midStr = getConnectionType().getDefaultLinkName();
usedConnType = true;
// avoid the not useful action, on connection.
if (tmpConnType == null || tmpConnType != null && tmpConnType == getConnectionType()) {
nb++;
}
}
}
if (nb < 2) {
return false;
}
multipleOutputNode = node;
//$NON-NLS-1$
setText(Messages.getString("ModifyOutputOrderAction.text", midStr));
return true;
}
use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.
the class NodeBreakpointAction method canPerformAction.
/**
* Test if the selected item is a node.
*
* @return true / false
*/
private boolean canPerformAction() {
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (!brandingService.getBrandingConfiguration().isAllowDebugMode()) {
return false;
}
if (getSelectedObjects().isEmpty()) {
return false;
}
if (PluginUtil.isMediation()) {
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();
if (node.getJobletNode() != null) {
return false;
}
EditPart parentPart = part.getParent();
while (!(parentPart instanceof ProcessPart)) {
parentPart = parentPart.getParent();
}
if (!(parentPart instanceof ProcessPart)) {
return false;
}
process = (IProcess) ((ProcessPart) parentPart).getModel();
if (CorePlugin.getContext().getBreakpointNodes(process).contains(node)) {
//$NON-NLS-1$
setText(Messages.getString("NodeBreakpointAction.removeBreakpoint"));
} else {
//$NON-NLS-1$
setText(Messages.getString("NodeBreakpointAction.addBreakPoint"));
}
return true;
}
return false;
}
Aggregations