Java Code Examples for org.eclipse.emf.ecore.EClass#equals()

The following examples show how to use org.eclipse.emf.ecore.EClass#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EClassifierInfo.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean addSupertype(EClassifierInfo superTypeInfo) {
	EClass eClass = getEClass();
	EClass superEClass = (EClass) superTypeInfo.getEClassifier();

	if (superEClass.isSuperTypeOf(eClass)) {
		return true;
	}

	if (!isGenerated()) {
		throw new IllegalStateException("Type " + this.getEClassifier().getName()
				+ " is not generated and cannot be modified.");
	}
	if (!(superTypeInfo instanceof EClassInfo)) {
		throw new IllegalArgumentException("superTypeInfo must represent EClass");
	}

	if (eClass.equals(superEClass))
		// cannot add class as it's own superclass
		// this usually happens due to a rule call
		return false;

	return eClass.getESuperTypes().add(superEClass);
}
 
Example 2
Source File: WidgetLabelProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getText(Object element) {
    EClass eClass = (EClass) element ;
    if(eClass.equals(ConnectorDefinitionPackage.Literals.TEXT)){
        return Messages.textWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.CHECKBOX)){
        return Messages.checkboxWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.PASSWORD)){
        return Messages.passwordWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.SELECT)){
        return Messages.selectWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.LIST)){
        return Messages.listWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.ARRAY)){
        return Messages.arrayWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.RADIO_GROUP)){
        return Messages.radioGroupWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.GROUP)){
        return Messages.groupWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.SCRIPT_EDITOR)){
        return Messages.scriptEditorWidgetLabel ;
    }else if(eClass.equals(ConnectorDefinitionPackage.Literals.TEXT_AREA)){
        return Messages.textAreaEditor ;
    }
    return super.getText(element);
}
 
Example 3
Source File: ActivityTypeSelectionGridPropertySectionContribution.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void refresh() {
    if (activity != null && combo != null) {
        EClass eClass = activity.eClass();
        if (eClass.equals(ProcessPackage.Literals.TASK)) {
            combo.setSelection(new StructuredSelection(ACTIVITY_TYPE__TASK));
        } else if (eClass.equals(ProcessPackage.Literals.CALL_ACTIVITY)) {
            combo.setSelection(new StructuredSelection(ACTIVITY_TYPE__CALL_ACTVITY));
        } else if (eClass.equals(ProcessPackage.Literals.ACTIVITY)) {
            combo.setSelection(new StructuredSelection(ACTIVITY_TYPE__SYSTEM));
        }else if (eClass.equals(ProcessPackage.Literals.RECEIVE_TASK)) {
            combo.setSelection(new StructuredSelection(ACTIVITY_TYPE__RECEIVE_TASK));
        }else if (eClass.equals(ProcessPackage.Literals.SEND_TASK)) {
            combo.setSelection(new StructuredSelection(ACTIVITY_TYPE__SEND_TASK));
        }else if (eClass.equals(ProcessPackage.Literals.SERVICE_TASK)) {
            combo.setSelection(new StructuredSelection(ACTIVITY_TYPE__SERVICE_TASK));
        }else if (eClass.equals(ProcessPackage.Literals.SCRIPT_TASK)) {
            combo.setSelection(new StructuredSelection(ACTIVITY_TYPE__SCRIPT_TASK));
        }
    }
}
 
Example 4
Source File: ExpressionScriptContrainer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public CompoundCommand updateDependencies(final TransactionalEditingDomain editingDomain,
        final List<? extends RefactorPair<? extends EObject, ? extends EObject>> pairsToRefactor) {
    final CompoundCommand compoundCommand = new CompoundCommand();
    final Expression expression = getModelElement();
    for (final EObject dep : expression.getReferencedElements()) {
        for (final RefactorPair<? extends EObject, ? extends EObject> pair : pairsToRefactor) {
            final String oldValueName = pair.getOldValueName();
            final EClass eClass = pair.getOldValue().eClass();
            if (eClass.equals(dep.eClass()) && oldValueName.equals(dependencyName(dep))) {
                EMFModelUpdater<EObject> updater = new EMFModelUpdater<>().from(dep);
                updater.editWorkingCopy(ExpressionHelper.createDependencyFromEObject(pair.getNewValue()));
                compoundCommand.append(updater.createUpdateCommand(editingDomain));
            }
        }
    }
    return compoundCommand;
}
 
Example 5
Source File: ExpressionScriptContrainer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public CompoundCommand removeDependencies(final TransactionalEditingDomain editingDomain,
        final List<? extends RefactorPair<? extends EObject, ? extends EObject>> pairsToRefactor) {
    final CompoundCommand compoundCommand = new CompoundCommand();
    final Expression expression = getModelElement();
    for (final EObject dep : expression.getReferencedElements()) {
        for (final RefactorPair<?, ? extends EObject> pair : pairsToRefactor) {
            final String oldValueName = pair.getOldValueName();
            final EClass eClass = pair.getOldValue().eClass();
            if (eClass.equals(dep.eClass()) && oldValueName.equals(dependencyName(dep))) {
                final Command removeCmd = RemoveCommand.create(editingDomain, expression,
                        ExpressionPackage.Literals.EXPRESSION__REFERENCED_ELEMENTS,
                        dep);
                if (!compoundCommand.getCommandList().contains(removeCmd)) {
                    compoundCommand.append(removeCmd);
                }
            }
        }
    }
    return compoundCommand;
}
 
Example 6
Source File: GatewayTypeSelectionGridPropertySectionContribution.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void refresh() {
if (gate != null && combo != null) {
    EClass eClass = gate.eClass();
    if (eClass.equals(ProcessPackage.Literals.AND_GATEWAY)) {
	combo.setText(GATEWAY_TYPE_AND);
    } else if (eClass.equals(ProcessPackage.Literals.XOR_GATEWAY)) {
	combo.setText(GATEWAY_TYPE_XOR);
    } else if (eClass.equals(ProcessPackage.Literals.INCLUSIVE_GATEWAY)) {
	combo.setText(GATEWAY_TYPE_INCLUSIVE);
    }
}
   }
 
Example 7
Source File: EcoreUtil2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
private static boolean isLooslyCompatibleWith(EClass classA, EClass classB) {
	return classA.equals(classB) || classA.getEAllSuperTypes().contains(classB)
			|| classB.getEAllSuperTypes().contains(classA);
}
 
Example 8
Source File: ActivityNodeResolver.java    From txtUML with Eclipse Public License 1.0 4 votes vote down vote up
public String getTargetFromActivityNode(ActivityNode node, boolean conditionalExpression) {
	if(node == null) {
		Logger.sys.error("This should not happen..");
	}

	String source = "UNHANDLED_ACTIVITYNODE";
	if (node.eClass().equals(UMLPackage.Literals.FORK_NODE) || node.eClass().equals(UMLPackage.Literals.JOIN_NODE)
			|| node.eClass().equals(UMLPackage.Literals.DECISION_NODE)) {
		source = getTargetFromActivityNode(node.getIncomings().get(0).getSource(), conditionalExpression);
	} else if (node.eClass().equals(UMLPackage.Literals.ADD_STRUCTURAL_FEATURE_VALUE_ACTION)) {
		source = getTargetFromInputPin(((AddStructuralFeatureValueAction) node).getObject());
	} else if (node.eClass().equals(UMLPackage.Literals.READ_STRUCTURAL_FEATURE_ACTION)) {
		source = getTargetFromRSFA((ReadStructuralFeatureAction) node);
	} else if (node.eClass().equals(UMLPackage.Literals.ACTIVITY_PARAMETER_NODE)) {
		EClass ec = node.getActivity().getOwner().eClass();
		String paramName = ((ActivityParameterNode) node).getParameter().getName();
		if (ec.equals(UMLPackage.Literals.TRANSITION)) {
			source = ActivityTemplates.transitionActionParameter(paramName);
		} else // the parameter is a function parameter
		{
			source = GenerationTemplates.paramName(paramName);
		}

	} else if (node.eClass().equals(UMLPackage.Literals.CREATE_OBJECT_ACTION)) {
		source = objectMap.get(node);
	} else if (node.eClass().equals(UMLPackage.Literals.READ_SELF_ACTION)) {
		source = ActivityTemplates.SelfLiteral;

	} else if (node.eClass().equals(UMLPackage.Literals.READ_LINK_ACTION)) {
		source = getTargetFromActivityNode(((ReadLinkAction) node).getResult(), conditionalExpression);

	} else if (node.eClass().equals(UMLPackage.Literals.OUTPUT_PIN)) {
		OutputPin outPin = (OutputPin) node;
		source = tempVariableExporter.isOutExported(outPin) ? 
				tempVariableExporter.getRealVariableName(outPin):
				 getTargetFromActivityNode((ActivityNode) node.getOwner(), conditionalExpression);

	} else if (node.eClass().equals(UMLPackage.Literals.VALUE_SPECIFICATION_ACTION)) {
		source = getValueFromValueSpecification(((ValueSpecificationAction) node).getValue());
	} else if (node.eClass().equals(UMLPackage.Literals.READ_VARIABLE_ACTION)) {

		ReadVariableAction rA = (ReadVariableAction) node;
		userVariableExporter.modifyVariableInfo(rA.getVariable());
		source = userVariableExporter.getRealVariableReference(rA.getVariable());
		if(rA.getVariable().getUpper() == 1 && conditionalExpression) {
			source = ActivityTemplates.operationCall(source, PointerAndMemoryNames.SimpleAccess, 
						CollectionNames.SelectAnyFunctionName, Collections.emptyList());
		}
	} else if (node.eClass().equals(UMLPackage.Literals.SEQUENCE_NODE)) {
		SequenceNode seqNode = (SequenceNode) node;
		int lastIndex = seqNode.getNodes().size() - 1;
		source = getTargetFromActivityNode(seqNode.getNodes().get(lastIndex), conditionalExpression);

	} else if (node.eClass().equals(UMLPackage.Literals.CALL_OPERATION_ACTION)) {
		CallOperationAction callAction = (CallOperationAction) node;
		source = tempVariableExporter.getRealVariableName(returnOutputsToCallActions.get(callAction));
	} else {
		Logger.sys.error("Unhandled activity node: " + node.getName());
	}
	return source;
}