Exemple #1
0
bool BasicData::tool_cmd(ToolCom * com, const char * args,
			 BrowserNode * bn, const QString & comment) {
  switch ((unsigned char) args[-1]) {
  case setStereotypeCmd:
    if (!bn->is_writable() && !root_permission())
      com->write_ack(FALSE);
    else {
      set_stereotype(args);
      browser_node->package_modified();
      modified();
      com->write_ack(TRUE);
    }
    break;
  case getDefCmd:
    send_uml_def(com, bn, comment);
    send_cpp_def(com);
    send_java_def(com);
    if (com->api_format() >= 34) {
      send_php_def(com);
      if (com->api_format() >= 39)
	send_python_def(com);
    }
    send_idl_def(com);
    break;
  case getUmlDefCmd:
    send_uml_def(com, bn, comment);
    break;
  case getCppDefCmd:
    send_uml_def(com, bn, comment);
    send_cpp_def(com);
    break;
  case getJavaDefCmd:
    send_uml_def(com, bn, comment);
    send_java_def(com);
    break;
  case getPhpDefCmd:
    send_uml_def(com, bn, comment);
    send_php_def(com);
    break;
  case getPythonDefCmd:
    send_uml_def(com, bn, comment);
    send_python_def(com);
    break;
  case getIdlDefCmd:
    send_uml_def(com, bn, comment);
    send_idl_def(com);
    break;
  default:
    return FALSE;
  }
  
  return TRUE;
}    
Exemple #2
0
bool RelationData::tool_cmd(ToolCom * com, BrowserRelation * rel,
                            const char * args)
{
    if (((unsigned char) args[-1]) >= firstSetCmd) {
        if (!rel->is_writable() && !root_permission())
            com->write_ack(FALSE);
        else {
            RoleData & r = (rel == start) ? a : b;

            switch ((unsigned char) args[-1]) {
            case setDescriptionCmd:
                r.comment = args;
                break;

            case setStereotypeCmd:
                set_stereotype(args);
                modified();
                com->write_ack(TRUE);

                // send the other side to update it
                if (rel == start) {
                    if (end != 0)
                        end->write_id(com);
                    else
                        com->write_id(0);
                }
                else
                    start->write_id(com);

                return TRUE;

            case setRelationAssocClassCmd: {
                AType t;

                com->get_type(t, args);
                set_association(t);
                modified();
                com->write_ack(TRUE);

                // send the other side to update it
                if (rel == start) {
                    if (end != 0)
                        end->write_id(com);
                    else
                        com->write_id(0);
                }
                else
                    start->write_id(com);
            }

            return TRUE;

            case setNameCmd:
                name = args;
                break;

            case setDefaultValueCmd:
                r.init_value = args;
                break;

            case setIsClassMemberCmd:
                r.isa_class_relation = (*args != 0);
                break;

            case setIsVolatileCmd:
                r.isa_volatile_relation = (*args != 0);
                break;

            case setVisibilityCmd: {
                UmlVisibility v;

                if (! com->get_visibility(v, args)) {
                    com->write_ack(FALSE);
                    return TRUE;
                }

                r.uml_visibility = v;
            }
            break;

            case setConstraintCmd:
                r.constraint = args;
                break;

            case setCppDeclCmd:
                r.cpp_decl = args;
                break;

            case setJavaDeclCmd:
                r.java_decl = args;
                break;

            case setJavaAnnotationCmd: {
                WrapperStr s = args;

                s = s.stripWhiteSpace();

                if (! s.isEmpty())
                    s += '\n';

                r.java_annotation = s;
            }
            break;

            case setPhpDeclCmd:
                r.php_decl = args;
                break;

            case setPythonDeclCmd:
                r.python_decl = args;
                break;

            case setIdlDeclCmd:
                r.idl_decl = args;
                break;

            case setCppVisibilityCmd: {
                UmlVisibility v;

                if (! com->get_visibility(v, args)) {
                    com->write_ack(FALSE);
                    return TRUE;
                }

                r.cpp_visibility = v;
            }
            break;

            case setIsReadOnlyCmd:
                r.isa_const_relation = (*args != 0);
                break;

            case setIsCppMutableCmd:
                r.cpp_mutable = (*args != 0);
                break;

            case setRoleNameCmd:
                if ((rel == start) ? wrong_role_a_name(args)
                    : wrong_role_b_name(args)) {
                    com->write_ack(FALSE);
                    return TRUE;
                }

                r.role = args;
                break;

            case setMultiplicityCmd:
                r.multiplicity = args;
                break;

            case setCppVirtualInheritanceCmd:
                r.cpp_virtual_inheritance = (*args != 0);
                break;

            case setIsIdlTruncatableCmd:
                r.idl_truncatable_inheritance = (*args != 0);;
                break;

            case setIsJavaTransientCmd:
                r.java_transient = (*args != 0);
                break;

            case setIdlCaseCmd: {
                BrowserAttribute * at = (BrowserAttribute *) com->get_id(args);

                set_idlcase(r, at, args);
            }
            break;

            case setDerivedCmd:
                switch (*args) {
                case 0:
                    r.is_derived = r.is_derivedunion = FALSE;
                    break;

                case 1:
                    r.is_derived = TRUE;
                    r.is_derivedunion = FALSE;
                    break;

                case 3:
                    r.is_derived = r.is_derivedunion = TRUE;
                    break;

                default:
                    // derived union but non derived
                    com->write_ack(FALSE);
                    return TRUE;
                }

                break;

            case setOrderingCmd:
                r.is_ordered = (*args != 0);
                break;

            case setUniqueCmd:
                r.is_unique = (*args != 0);
                break;

            case setTypeCmd:
                // only inside associations
            {
                UmlCode c;

                if (!com->get_relation_kind(c, args)) {
                    com->write_ack(FALSE);
                    return TRUE;
                }
                else {
                    type = c;

                    if (end)
                        end->package_modified();

                    if (check_end_visibility())
                        end->modified();

                    start->modified();
                    start->package_modified();
                    modified();
                }
            }
            break;

            default:
                return FALSE;
            }

            // ok case
            if (rel == start) {
                start->modified();
                start->package_modified();
            }
            else {
                end->modified();
                end->package_modified();
            }

            modified();
            com->write_ack(TRUE);
        }
    }
    else {
        switch ((unsigned char) args[-1]) {
        case getDefCmd:
            send_uml_def(com, rel);
            send_cpp_def(com, rel);
            send_java_def(com, rel);

            if (com->api_format() >= 34) {
                send_php_def(com, rel);

                if (com->api_format() >= 39)
                    send_python_def(com, rel);
            }

            send_idl_def(com, rel);
            break;

        case getUmlDefCmd:
            send_uml_def(com, rel);
            break;

        case getCppDefCmd:
            send_uml_def(com, rel);
            send_cpp_def(com, rel);
            break;

        case getJavaDefCmd:
            send_uml_def(com, rel);
            send_java_def(com, rel);
            break;

        case getPhpDefCmd:
            send_uml_def(com, rel);
            send_php_def(com, rel);
            break;

        case getPythonDefCmd:
            send_uml_def(com, rel);
            send_python_def(com, rel);
            break;

        case getIdlDefCmd:
            send_uml_def(com, rel);
            send_idl_def(com, rel);
            break;

        case sideCmd:
            if (*args)
                start->write_id(com);
            else if (end != 0)
                end->write_id(com);
            else
                com->write_id(0);

            break;

        default:
            return FALSE;
        }
    }

    return TRUE;
}