Exemplo n.º 1
0
ActivityDiagram::CONNECT_ERROR_TYPE ActivityDiagram::canConnectGlyph(int fromId, int toId)
{
	Glyph *fromGlyph = getGlyphById(fromId);
	Glyph *toGlyph = getGlyphById(toId);

	if (fromGlyph == toGlyph) // 連到自己
		return CONNECT_ITSELF;
	else if (toGlyph->getType() == INITIAL_NODE) // 連到InitialNode
		return CANNOT_BE_CONNECTED;
	else if (fromGlyph->getType() == FINAL_NODE) // 由FinalNode連出
		return CANNOT_CONNECT;
	else if (fromGlyph->canAddTarget(toGlyph) && toGlyph->canAddSource(fromGlyph)) // 成功
		return SUCCESS;
	else // 其他錯誤
		return OTHER_ERROR;
}