use of org.talend.designer.core.ui.editor.connections.ConnectionLabel in project tdi-studio-se by Talend.
the class ComponentSettingsView method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
this.parent = parent;
tabFactory.initComposite(parent, true);
tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
if (descriptor == null) {
return;
}
if (currentSelectedTab != null && (!currentSelectedTab.getData().equals(descriptor.getData()) || currentSelectedTab.getCategory() != descriptor.getCategory())) {
for (Control curControl : tabFactory.getTabComposite().getChildren()) {
curControl.dispose();
}
}
if (element == null || !element.equals(descriptor.getData()) || currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
element = (Element) descriptor.getData();
currentSelectedTab = descriptor;
if (descriptor.getData() instanceof ConnectionLabel) {
createDynamicComposite(tabFactory.getTabComposite(), ((ConnectionLabel) descriptor.getData()).getConnection(), descriptor.getCategory());
} else {
createDynamicComposite(tabFactory.getTabComposite(), (Element) descriptor.getData(), descriptor.getCategory());
}
selectedPrimary = false;
}
}
});
}
use of org.talend.designer.core.ui.editor.connections.ConnectionLabel in project tdi-studio-se by Talend.
the class ActivateElementAction 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);
nodeList = new ArrayList<Node>();
for (int i = 0; i < parts.size(); i++) {
if (parts.get(i) instanceof NodePart) {
Node node = ((Node) ((NodePart) parts.get(i)).getModel());
if ((!node.isReadOnly()) && (node.getPropertyValue(EParameterName.ACTIVATE.getName()) != null)) {
nodeList.add(node);
}
}
}
connectionList = new ArrayList<Connection>();
for (int i = 0; i < parts.size(); i++) {
if (parts.get(i) instanceof ConnectionPart) {
Connection connection = ((Connection) ((ConnectionPart) parts.get(i)).getModel());
if (!connection.isReadOnly() && connection.getSource().isActivate() && connection.getTarget().isActivate()) {
connectionList.add(connection);
}
}
if (parts.get(i) instanceof ConnLabelEditPart) {
Connection connection = ((ConnectionLabel) ((ConnLabelEditPart) parts.get(i)).getModel()).getConnection();
if (!connection.isReadOnly() && connection.getSource().isActivate() && connection.getTarget().isActivate()) {
connectionList.add(connection);
}
}
}
if ((nodeList.size() == 0) && (connectionList.size() == 0)) {
return false;
}
for (Node node : nodeList) {
if (node.getJobletNode() != null) {
return false;
}
}
for (Connection conn : connectionList) {
if (conn.getTarget().getJobletNode() != null && conn.getSource().getJobletNode() != null) {
return false;
}
}
if (nodeList.size() != 0) {
if (nodeList.get(0).isActivate()) {
if (nodeList.size() == 1) {
//$NON-NLS-1$
setText(TEXT_REM_ACTIVATE + " " + nodeList.get(0).getLabel());
} else {
setText(TEXT_REM_ACTIVATE);
}
} else {
if (nodeList.size() == 1) {
//$NON-NLS-1$
setText(TEXT_SET_ACTIVATE + " " + nodeList.get(0).getLabel());
} else {
setText(TEXT_SET_ACTIVATE);
}
activate = true;
}
} else {
// connections only
if (connectionList.get(0).isActivate()) {
if (connectionList.size() == 1) {
//$NON-NLS-1$
setText(TEXT_REM_ACTIVATE + " " + connectionList.get(0).getName());
} else {
setText(TEXT_REM_ACTIVATE);
}
} else {
if (connectionList.size() == 1) {
//$NON-NLS-1$
setText(TEXT_SET_ACTIVATE + " " + connectionList.get(0).getName());
} else {
setText(TEXT_SET_ACTIVATE);
}
activate = true;
}
}
return true;
}
return false;
}
use of org.talend.designer.core.ui.editor.connections.ConnectionLabel in project tdi-studio-se by Talend.
the class ComponentSettingsView method getCategories.
/**
* yzhang Comment method "getCategories".
*
* @param elem
* @return
*/
private EComponentCategory[] getCategories(Element elem) {
if (elem instanceof Connection) {
EComponentCategory[] categories = EElementType.CONNECTION.getCategories();
if (PluginChecker.isTeamEdition()) {
Object propertyValue = elem.getPropertyValue(Connection.LINESTYLE_PROP);
if (propertyValue instanceof EConnectionType && ((EConnectionType) propertyValue).hasConnectionCategory(IConnectionCategory.FLOW)) {
// if (((Connection) elem).checkTraceShowEnable()) {
final List<EComponentCategory> list = new ArrayList<EComponentCategory>(Arrays.asList(categories));
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
// mrjob and stormjob not add breakpoint
if (!isStormProcess && !isMRProcess) {
list.add(EComponentCategory.BREAKPOINT);
}
if (elem.getElementParameter(EParameterName.DEPARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.PARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.REPARTITIONER.getName()) != null) {
list.add(EComponentCategory.PARALLELIZATION);
}
// if it mr group line then add errorRecovery
if (isMRProcess && isMrGroupLine(elem)) {
list.add(EComponentCategory.RESUMING);
}
return list.toArray(new EComponentCategory[0]);
// }
} else if (propertyValue.equals(EConnectionType.ON_COMPONENT_OK) || propertyValue.equals(EConnectionType.ON_COMPONENT_ERROR) || propertyValue.equals(EConnectionType.RUN_IF) || propertyValue.equals(EConnectionType.ON_SUBJOB_OK) || propertyValue.equals(EConnectionType.ON_SUBJOB_ERROR) || propertyValue.equals(EConnectionType.ROUTE_WHEN) || propertyValue.equals(EConnectionType.ROUTE_CATCH) || propertyValue.equals(EConnectionType.STARTS)) {
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
int length = categories.length;
EComponentCategory[] newCategories;
boolean isNormalJobNeedRecovery = (!isMRProcess && !isStormProcess && !isAvoidRecoveryByConditions(elem));
boolean isMrStormJobNeedRecovery = isMRProcess || isStormProcess;
if (isNeedRecoveryCategory(propertyValue, isNormalJobNeedRecovery, isMrStormJobNeedRecovery)) {
newCategories = new EComponentCategory[length + 1];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
EComponentCategory resuming = EComponentCategory.RESUMING;
newCategories[length] = resuming;
} else {
newCategories = new EComponentCategory[length];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
}
return newCategories;
}
}
return categories;
} else if (elem instanceof Node) {
// if (isAdvancedType(elem)) {
if (((Node) elem).isELTComponent()) {
if (//$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Output") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Input") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Map") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("TableList") && !((Node) elem).getComponent().getName().endsWith("ColumnList")) {
//$NON-NLS-1$
return EElementType.ELT_NODE.getCategories();
}
}
EComponentCategory[] categories = EElementType.ADVANCED_NODE.getCategories();
// add for bug TDI-8476
if (((Node) elem).getComponent() != null) {
String paletteType = ((Node) elem).getComponent().getPaletteType();
if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(paletteType)) {
categories = EElementType.NODE.getCategories();
}
}
if (PluginChecker.isValidationrulesPluginLoaded() && isSupportValidationRuleNode((Node) elem)) {
// show
EComponentCategory[] newCategories = new EComponentCategory[categories.length + 1];
System.arraycopy(categories, 0, newCategories, 0, categories.length);
newCategories[categories.length] = EComponentCategory.VALIDATION_RULES;
return newCategories;
}
return categories;
} else if (elem instanceof Note) {
return EElementType.NOTE.getCategories();
} else if (elem instanceof SubjobContainer) {
return EElementType.SUBJOB.getCategories();
} else if (elem instanceof ConnectionLabel) {
return getCategories(((ConnectionLabel) elem).getConnection());
}
return null;
}
use of org.talend.designer.core.ui.editor.connections.ConnectionLabel in project tdi-studio-se by Talend.
the class GEFDeleteAction method calculateEnabled.
@Override
protected boolean calculateEnabled() {
objectsToDelete = new ArrayList();
List objects = getSelectedObjects();
objectsToDelete.addAll(objects);
if (objects.isEmpty() || (objects.size() == 1 && objects.get(0) instanceof ProcessPart)) {
return false;
}
if (!(objects.get(0) instanceof EditPart)) {
return false;
}
AbstractTalendEditor editor = (AbstractTalendEditor) this.getWorkbenchPart();
AbstractProcessProvider pProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (pProvider != null) {
Map<JobletContainerPart, List<NodePart>> jobletMap = new HashMap<JobletContainerPart, List<NodePart>>();
boolean nodeInJoblet = false;
boolean allJunitnode = true;
boolean hasNode = false;
int i = 0;
for (Object o : objects) {
if (o instanceof NodePart) {
hasNode = true;
NodePart nodePart = (NodePart) o;
Node no = (Node) ((NodePart) o).getModel();
if (no.getProcess().isReadOnly()) {
return false;
}
if (no.isReadOnly()) {
i++;
}
if (no.getJunitNode() == null) {
allJunitnode = false;
}
if (!pProvider.canDeleteNode(no)) {
return false;
}
boolean isCollapsedNode = false;
if (editor.getProcess().getGraphicalNodes().contains(nodePart.getModel())) {
isCollapsedNode = true;
}
if (!isCollapsedNode && nodePart.getParent() instanceof JobletContainerPart) {
JobletContainerPart jobletContainer = (JobletContainerPart) nodePart.getParent();
List<NodePart> jobletNodeParts = jobletMap.get(jobletContainer);
if (jobletNodeParts == null) {
jobletNodeParts = new ArrayList<NodePart>();
jobletMap.put(jobletContainer, jobletNodeParts);
}
jobletNodeParts.add(nodePart);
}
} else if (o instanceof ConnectionPart) {
Connection conn = (Connection) ((ConnectionPart) o).getModel();
if (conn.getSource().getProcess().isReadOnly()) {
return false;
}
if (conn.isReadOnly()) {
i++;
}
} else if (o instanceof ConnLabelEditPart) {
ConnectionLabel connLabel = (ConnectionLabel) ((ConnLabelEditPart) o).getModel();
if (connLabel.getConnection().getSource().getProcess().isReadOnly()) {
return false;
}
if (connLabel.getConnection().isReadOnly()) {
i++;
}
} else if (o instanceof NoteEditPart) {
allJunitnode = false;
Note note = (Note) ((NoteEditPart) o).getModel();
if (note.isReadOnly()) {
i++;
}
} else if (o instanceof SubjobContainerPart) {
SubjobContainer subjob = (SubjobContainer) ((SubjobContainerPart) o).getModel();
if (subjob.getProcess().isReadOnly()) {
return false;
}
if (subjob.isReadOnly()) {
i++;
continue;
}
boolean isAllReadonly = true;
boolean subjobAllJunit = true;
for (NodeContainer nc : subjob.getNodeContainers()) {
Node node = nc.getNode();
if (!node.isReadOnly()) {
isAllReadonly = false;
}
if (node.getJunitNode() == null) {
subjobAllJunit = false;
}
}
if (isAllReadonly || subjobAllJunit) {
i++;
}
}
}
for (JobletContainerPart jobletContainer : jobletMap.keySet()) {
boolean copyJobletNode = true;
List<NodePart> list = jobletMap.get(jobletContainer);
for (Object obj : jobletContainer.getChildren()) {
if (obj instanceof NodePart) {
if (!list.contains(obj)) {
copyJobletNode = false;
break;
}
}
}
if (copyJobletNode) {
objectsToDelete.removeAll(list);
PartFactory factory = new PartFactory();
NodePart createEditPart = (NodePart) factory.createEditPart(jobletContainer, ((NodeContainer) jobletContainer.getModel()).getNode());
createEditPart.setParent(jobletContainer);
createEditPart.installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
objectsToDelete.add(createEditPart);
} else {
nodeInJoblet = true;
}
}
if (((nodeInJoblet || allJunitnode) && hasNode) || i == objects.size()) {
return false;
}
}
return true;
}
use of org.talend.designer.core.ui.editor.connections.ConnectionLabel in project tdi-studio-se by Talend.
the class ComponentSettingsView method setPropertiesViewerTitle.
/**
* yzhang Comment method "setPropertiesViewerTitle".
*
* @param elem
*/
private void setPropertiesViewerTitle(Element elem) {
String label = null;
Image image = null;
if (elem instanceof Node) {
label = ((Node) elem).getLabel();
String uniqueName = ((Node) elem).getUniqueName();
if (!label.equals(uniqueName)) {
//$NON-NLS-1$ //$NON-NLS-2$
label = label + "(" + uniqueName + ")";
}
image = CoreImageProvider.getComponentIcon(((Node) elem).getComponent(), ICON_SIZE.ICON_24);
} else if (elem instanceof Connection) {
label = ((Connection) elem).getElementName();
image = ImageProvider.getImage(EImage.RIGHT_ICON);
} else if (elem instanceof Note) {
//$NON-NLS-1$
label = Messages.getString("ComponentSettingsView.note");
image = ImageProvider.getImage(EImage.PASTE_ICON);
} else if (elem instanceof SubjobContainer) {
//$NON-NLS-1$
label = Messages.getString("ComponentSettingsView.subjob");
image = ImageProvider.getImage(EImage.PASTE_ICON);
} else if (elem instanceof ConnectionLabel) {
label = ((ConnectionLabel) elem).getConnection().getElementName();
image = ImageProvider.getImage(EImage.RIGHT_ICON);
}
tabFactory.setTitle(label, image);
super.setTitleToolTip(label);
}
Aggregations