/** * Validate if the freeTextGraphNode is valid for actions that relates to Free Text graph nodes. * * @param freeTextGraphNode the freeTextGraphNode to validate * @throws IllegalArgumentException If freeTextGraphNode is null, or the freeTextGraphNode doesn't * contain a semanticModel attribute (<code>SimpleSemanticModelElement</code> object) with * typeInfo attribute equal to "FreeText", or it doesn't contain a <code>TextElement</code> * object in its contained attribute. */ static void validateGraphNodeForFreeTextAction(GraphNode freeTextGraphNode) { if (freeTextGraphNode == null) { throw new IllegalArgumentException("freeTextGraphNode cannot be null!"); } // Validate the SemanticModel SemanticModelBridge smb = freeTextGraphNode.getSemanticModel(); if (!(smb instanceof SimpleSemanticModelElement)) { throw new IllegalArgumentException( "SemanticModel of the freeTextGraphNode should be SimpleSemanticModelElement!"); } SimpleSemanticModelElement ssme = (SimpleSemanticModelElement) smb; if (!FREE_TEXT.equals(ssme.getTypeInfo())) { throw new IllegalArgumentException( "typeInfo of freeTextGraphNode's SemanticModel should be '" + FREE_TEXT + "'!"); } // Validate if the freeTextGraphNode contains a TextElement boolean valid = false; for (DiagramElement de : freeTextGraphNode.getContaineds()) { if (de instanceof TextElement) { valid = true; break; } } if (!valid) { throw new IllegalArgumentException("freeTextGraphNode should contain a TextElement!"); } }
/** Creates the graph node for new node. */ protected void createGraphNode() { graphNode = DeployHelper.createGraphNodeForClass(element, position, size); NodeContainer nodeContainer = getNodeContainer(); if (nodeContainer != null) { GraphNode container = nodeContainer.getGraphNode(); GraphNode bodyCompartment = (GraphNode) container.getContaineds().get(1); setAddDiagramElementAction( new AddDiagramElementAction( bodyCompartment, graphNode, modelManager.getProjectConfigurationManager())); } else { setAddDiagramElementAction( new AddDiagramElementAction( getDiagramView().getDiagram(), graphNode, modelManager.getProjectConfigurationManager())); } }