if(xSelectedShape != null){
XNamed xNamed = (XNamed) UnoRuntime.queryInterface( XNamed.class, xSelectedShape );
String selectedShapeName = xNamed.getName();
int iTopShapeID = -1;
if(selectedShapeName.contains("RectangleShape") && !selectedShapeName.contains("RectangleShape0")){
TreeItem selectedItem = m_DiagramTree.getTreeItem(xSelectedShape);
// can't be associate of root item
if(selectedItem.getDad() == null && m_sNewItemHType == 1 ) {
String title = getGui().getDialogPropertyValue("Strings", "ItemAddError.Title");
String message = getGui().getDialogPropertyValue("Strings", "ItemAddError.Message");
getGui().showMessageBox(title, message);
}else{
iTopShapeID = getTopShapeID();
if( iTopShapeID <= 0 ){
clearEmptyDiagramAndReCreate();
}else{
iTopShapeID++;
XShape xRectangleShape = createShape("RectangleShape", iTopShapeID);
m_xShapes.add(xRectangleShape);
setMoveProtectOfShape(xRectangleShape);
setTextFitToSize(xRectangleShape);
setShapeProperties(xRectangleShape, "RectangleShape");
int color = -1;
if(getGui() != null && getGui().getControlDialogWindow() != null)
color = getGui().getImageColorOfControlDialog();
if(color < 0)
color = COLOR;
setColorOfShape(xRectangleShape, color);
m_DiagramTree.addToRectangles(xRectangleShape);
TreeItem newTreeItem = null;
TreeItem dadItem = null;
if(m_sNewItemHType == UNDERLING){
dadItem = selectedItem;
newTreeItem = new SOTreeItem(m_DiagramTree, xRectangleShape, dadItem, (short)0 , 0.0);
if(!dadItem.isFirstChild()){
dadItem.setFirstChild(newTreeItem);
}else{
XShape xPreviousChild = m_DiagramTree.getLastChildShape(xSelectedShape);
if(xPreviousChild != null){
TreeItem previousItem = m_DiagramTree.getTreeItem(xPreviousChild);
if(previousItem != null)
previousItem.setFirstSibling(newTreeItem);
}
}
}else if(m_sNewItemHType == ASSOCIATE){
dadItem = selectedItem.getDad();
newTreeItem = new SOTreeItem(m_DiagramTree, xRectangleShape, dadItem, (short)0, 0.0);