예제 #1
0
 public override void Visit(UMLDes.Model.UmlObject.Visitor v, UmlObject parent)
 {
     //if( Members != null )
     //	foreach( UmlObject o in Members )
     //		o.Visit( v, this );
     v(this, parent);
 }
예제 #2
0
파일: Model.cs 프로젝트: presscad/BaseLayer
        public static string GetUniversal(UmlObject obj)
        {
            string name = obj.Name;

            if (name == null || name.Length == 0)
            {
                return(String.Empty);
            }
            while (obj.Parent != null)
            {
                obj = obj.Parent;
                if (obj.Name != null && obj.Name.Length > 0)
                {
                    name = obj.Name + "." + name;
                }
                else
                {
                    while (obj.Parent != null && !(obj is UmlProject))
                    {
                        obj = obj.Parent;
                    }
                    if (obj != null)
                    {
                        name = ((UmlProject)obj).uid + "/" + name;
                    }

                    break;
                }
            }
            return(name);
        }
예제 #3
0
파일: Model.cs 프로젝트: presscad/BaseLayer
 public override void Visit(UMLDes.Model.UmlObject.Visitor v, UmlObject parent)
 {
     if (root != null)
     {
         root.Visit(v, this);
     }
     v(this, parent);
 }
예제 #4
0
파일: Model.cs 프로젝트: presscad/BaseLayer
        public UmlObject GetObject(string name)
        {
            int index = name.IndexOf('/');

            if (index == -1)
            {
                return(null);
            }
            string     proj_name = name.Substring(0, index);
            UmlProject project   = null;

            foreach (UmlProject p in projects)
            {
                if (p.uid.Equals(proj_name))
                {
                    project = p;
                    break;
                }
            }
            if (project == null)
            {
                foreach (UmlProject p in dllprojs)
                {
                    if (p.uid.Equals(proj_name))
                    {
                        project = p;
                        break;
                    }
                }
            }

            if (project != null)
            {
                UmlObject o     = project.root;
                string[]  genid = name.Substring(index + 1).Split(new char[] { '.' });
                foreach (string s in genid)
                {
                    Hashtable hash = null;
                    if (o is UmlNamespace)
                    {
                        hash = ((UmlNamespace)o).Children;
                    }
                    else if (o is UmlClass)
                    {
                        hash = ((UmlClass)o).Children;
                    }
                    if (hash == null || !hash.ContainsKey(s))
                    {
                        return(null);
                    }
                    o = (UmlObject)hash[s];
                }
                return(o);
            }

            return(null);
        }
예제 #5
0
 public override void Visit(Visitor v, UmlObject parent )
 {
     if( Types != null )
         foreach( UmlObject o in Types )
             o.Visit( v, this );
     if( Members != null )
         foreach( UmlObject o in Members )
             o.Visit( v, this );
     v( this, parent );
 }
예제 #6
0
 public static GuiItem CreateElement( UmlObject obj )
 {
     if( obj is UmlClass )
         return GuiClass.fromUML( obj as UmlClass );
     else if( obj is UmlEnum )
         return GuiEnum.fromUML( obj as UmlEnum );
     else if( obj is UmlNamespace )
         return GuiPackage.fromUML( obj as UmlNamespace );
     else
         return null;
 }
예제 #7
0
파일: Model.cs 프로젝트: presscad/BaseLayer
 public override void Visit(Visitor v, UmlObject parent)
 {
     foreach (UmlProject proj in projects)
     {
         proj.Visit(v, this);
     }
     foreach (UmlProject proj in dllprojs)
     {
         proj.Visit(v, this);
     }
 }
예제 #8
0
 public static string GetFullQualified( UmlObject obj )
 {
     string name = obj.Name;
     if( name == null || name.Length == 0 )
         return String.Empty;
     while( obj.Parent != null ) {
         obj = obj.Parent;
         if( obj.Name != null && obj.Name.Length > 0 )
             name = obj.Name + "." + name;
         else
             break;
     }
     return name;
 }
예제 #9
0
 public override void Visit(Visitor v, UmlObject parent)
 {
     if (Types != null)
     {
         foreach (UmlObject o in Types)
         {
             o.Visit(v, this);
         }
     }
     if (Members != null)
     {
         foreach (UmlObject o in Members)
         {
             o.Visit(v, this);
         }
     }
     v(this, parent);
 }
예제 #10
0
파일: Model.cs 프로젝트: presscad/BaseLayer
 public override void Visit(Visitor v, UmlObject parent)
 {
     if (SubNamespaces != null)
     {
         foreach (UmlNamespace o in SubNamespaces)
         {
             o.Visit(v, this);
         }
     }
     if (Types != null)
     {
         foreach (UmlType o in Types)
         {
             o.Visit(v, this);
         }
     }
     v(this, parent);
 }
예제 #11
0
파일: Model.cs 프로젝트: presscad/BaseLayer
        public static string GetFullQualified(UmlObject obj)
        {
            string name = obj.Name;

            if (name == null || name.Length == 0)
            {
                return(String.Empty);
            }
            while (obj.Parent != null)
            {
                obj = obj.Parent;
                if (obj.Name != null && obj.Name.Length > 0)
                {
                    name = obj.Name + "." + name;
                }
                else
                {
                    break;
                }
            }
            return(name);
        }
예제 #12
0
        private UmlType ResolveType( string typename, UmlObject context )
        {
            UmlType res;
            UsingBlock usings = null, cusings;
            UmlProject proj = GetProject( context );
            UmlObject current = context;
            int index = typename.IndexOf( '.' );
            string N = index == -1 ? typename : typename.Substring( 0, index ), I = index == -1 ? null : typename.Substring( index + 1 );

            while( current != null ) {

                // calculate usings
                if( usings == null && current is UmlType )
                    usings = ((UmlType)current).using_chain;
                if( usings != null && usings.related == current ) {
                    cusings = usings;
                    usings = usings.parent;
                } else
                    cusings = null;

            restart_search:

                // search in current scope
                if( current is UmlTypeHolder ) {
                    res = SearchInScope( proj.refs, current, typename );
                    if( res != null )
                        return res;

                    if( cusings != null ) {
                        if( cusings.aliases.ContainsKey( N ) ) {
                            string right = (string)cusings.aliases[N];
                            if( I != null )
                                return SearchInUsing( proj.refs, proj, right, I, UmlModel.GetFullQualified(current) );
                            else {
                                // restart search in the current scope with new typename
                                typename = right;
                                index = typename.IndexOf( '.' );
                                N = index == -1 ? typename : typename.Substring( 0, index );
                                I = index == -1 ? null : typename.Substring( index + 1 );
                                goto restart_search;
                            }

                        }

                        foreach( string use in cusings.list ) {

                            res = SearchInUsing( proj.refs, proj, use, typename, UmlModel.GetFullQualified(current) );
                            if( res != null )
                                return res;
                        }
                    }

                    // try base
                    if( current is UmlClass ) {
                        UmlClass cl = (UmlClass)current;
                        while( cl.BaseList != null && cl.BaseList.Count > 0 ) {
                            UmlObject base_class = (UmlObject)cl.BaseList[0];
                            if( base_class is UmlClass )
                                cl = (UmlClass)base_class;
                            else
                                break;
                            res = SearchInScope( null, cl, typename );
                            if( res != null )
                                return res;
                        }

                    }
                }

                // one step up
                current = current.Parent;
                if( current.Kind == UmlKind.Project )
                    break;
            }

            return null;
        }
예제 #13
0
 /// <summary>
 /// Gets UmlProject for UmlObject
 /// </summary>
 private UmlProject GetProject( UmlObject o )
 {
     while( o != null && o.Kind != UmlKind.Project )
         o = o.Parent;
     if( o != null )
         return (UmlProject)o;
     System.Diagnostics.Debug.Fail( "element has no project" );
     return null;
 }
예제 #14
0
        private string GetFullTypeName( string name, UmlObject context )
        {
            int index_sq = name.IndexOf( '[' ), index_star = name.IndexOf( '*' );
            int index;

            if( name.Equals( "void" ) )
                return name;

            if( index_sq == -1 )
                index = index_star;
            else if( index_star == -1 )
                index = index_sq;
            else
                index = Math.Min( index_sq, index_star );

            string qual_name = name;
            if( index >= 0 )
                qual_name = name.Substring( 0, index );

            UmlType type = ResolveType( qual_name, context );
            if( type == null ) {
                errors.Add( "type is not resolved in " + UmlModel.GetUniversal( context ) + ": " + name );
                return name;
            }
            qual_name = UmlModel.GetUniversal( type );
            if( index >= 0 )
                return qual_name + name.Substring( index );
            return qual_name;
        }
예제 #15
0
        private static void SetParentAndBuildHash( UmlObject elem, UmlObject parent )
        {
            elem.Parent = parent;
            if( elem is UmlClass ) {
                // hash class Children
                UmlClass cl = (UmlClass)elem;
                if( cl.Children == null )
                    cl.Children = new Hashtable();
                else
                    cl.Children.Clear();
                if( cl.Types != null )
                    foreach( UmlType t in cl.Types )
                        cl.Children[t.name] = t;

            } else if( elem is UmlNamespace ) {
                // hash namespace Children
                UmlNamespace ns = (UmlNamespace)elem;
                if( ns.Children == null )
                    ns.Children = new Hashtable();
                else
                    ns.Children.Clear();
                if( ns.Types != null )
                    foreach( UmlType t in ns.Types )
                        ns.Children[t.name] = t;
                if( ns.SubNamespaces != null )
                    foreach( UmlNamespace n in ns.SubNamespaces )
                        ns.Children[n.name] = n;
            }
        }
예제 #16
0
 private static void SetDeletedFlag( UmlObject elem, UmlObject parent )
 {
     elem.Deleted = true;
 }
예제 #17
0
 /// <summary>
 /// determines the visibility of the element (looks at modifiers)
 /// </summary>
 /// <param name="e">C# element</param>
 /// <returns>0 - public, 1 - private, 2 - protected</returns>
 private static int access_of_modifier( UmlObject e )
 {
     if( e is UmlMember )
         switch( ((UmlMember)e).visibility ) {
             case UmlVisibility.Public:
                 return 0;
             case UmlVisibility.Internal:
             case UmlVisibility.Private:
                 return 1;
             case UmlVisibility.Protected:
             case UmlVisibility.ProtectedInternal:
                 return 2;
         }
     else if( e is UmlClass )
         return 0; // TODO
     return 1;
 }
예제 #18
0
 public override void Visit(UMLDes.Model.UmlObject.Visitor v, UmlObject parent)
 {
     v(this, parent);
 }
예제 #19
0
        /// <summary>
        /// returns the number of icon for the given element
        /// </summary>
        /// <param name="e">C# element</param>
        public static int IconForElement( UmlObject e )
        {
            switch( e.Kind ) {
                case UmlKind.Project:
                    return 1;
                case UmlKind.Namespace:
                    return 5;
                case UmlKind.Class:
                    return 6 + access_of_modifier(e);
                case UmlKind.Interface:
                    return 9 + access_of_modifier(e);
                case UmlKind.Struct:
                    return 12 + access_of_modifier(e);
                case UmlKind.Method: case UmlKind.Constructor: case UmlKind.Destructor:
                    return 15 + access_of_modifier(e);
                case UmlKind.Delegate:
                    return 18 + access_of_modifier(e);
                case UmlKind.Enum:
                    return 21 + access_of_modifier(e);
                case UmlKind.Field: case UmlKind.Constant:
                    return 25 + access_of_modifier(e);
                case UmlKind.Event:
                    return 28 + access_of_modifier(e);
                case UmlKind.Indexer:
                    return 31 + access_of_modifier(e);
                case UmlKind.Operator:
                    return 34;
            }

            // unknown element, strange
            return 24;
        }
예제 #20
0
 public override void Visit(UMLDes.Model.UmlObject.Visitor v, UmlObject parent )
 {
     //if( Members != null )
     //	foreach( UmlObject o in Members )
     //		o.Visit( v, this );
     v( this, parent );
 }
예제 #21
0
        void get_children( UmlObject obj, ArrayList to )
        {
            if( obj is UmlProject )
                obj = ((UmlProject)obj).root;

            UmlTypeHolder from = obj as UmlTypeHolder;

            if( from == null )
                return;

            UmlNamespace ns = from as UmlNamespace;
            if( ns != null && ns.SubNamespaces != null )
                foreach( UmlObject s in ns.SubNamespaces )
                    to.Add( s );

            foreach( UmlObject s in ((UmlTypeHolder)from).Types )
                to.Add( s );

            if( from is UmlClass ) {
                UmlClass cl = (UmlClass)from;
                if( cl.Members != null )
                    foreach( UmlObject m in cl.Members )
                        to.Add( m );
            }
        }
예제 #22
0
 public override void Visit(UMLDes.Model.UmlObject.Visitor v, UmlObject parent)
 {
     v( this, parent );
 }
예제 #23
0
 /// <summary>
 /// Search child with spec name in type or Namespace
 /// </summary>
 private UmlObject SearchInTypeOrNS( UmlObject o, string name )
 {
     Hashtable hash = null;
     if( o is UmlNamespace )
         hash = ((UmlNamespace)o).Children;
     else if( o is UmlClass )
         hash = ((UmlClass)o).Children;
     if( hash == null || !hash.ContainsKey( name ) )
         return null;
     return (UmlObject)hash[name];
 }
예제 #24
0
파일: Model.cs 프로젝트: presscad/BaseLayer
 public virtual void Visit(Visitor v, UmlObject parent)
 {
 }
예제 #25
0
        /// <summary>
        /// Search typename in current context including referenced projects
        /// </summary>
        private UmlType SearchInScope( ArrayList refs, UmlObject cont, string typename )
        {
            string qual_name = GetQualifiedName( cont );
            UmlType res;

            // search in the current project
            res = SearchInside( cont, typename );
            if( res != null )
                return res;

            // search referenced projects
            if( refs != null )
                foreach( UmlProject r in refs ) {
                    UmlObject ns = GetTypeOrNS( r, qual_name );
                    if( ns != null ) {
                        res = SearchInside( ns, typename );
                        if( res != null )
                            return res;
                    }
                }
            return null;
        }
예제 #26
0
        /// <summary>
        /// Search type in object
        /// </summary>
        private UmlType SearchInside( UmlObject N, string I )
        {
            if( I == null )
                return N as UmlType;

            foreach( string s in I.Split( new char[] { '.' } ) ) {
                N = SearchInTypeOrNS( N, s );
                if( N == null )
                    break;
            }
            return N as UmlType;
        }
예제 #27
0
 public override void Visit(UMLDes.Model.UmlObject.Visitor v, UmlObject parent)
 {
     if( root != null )
         root.Visit( v, this );
     v( this, parent );
 }
예제 #28
0
 public void VisitClassAndImport( UmlObject v, UmlObject parent )
 {
     if( v.Kind == UmlKind.Class || v.Kind == UmlKind.Interface ) {
         if( ((UmlClass)v).BaseObjects != null )
             foreach( string s in ((UmlClass)v).BaseObjects )
                 if( s.Equals( name ) )
                     ImportClass( (UmlClass)v );
     }
 }
예제 #29
0
        public static string GetUniversal( UmlObject obj )
        {
            string name = obj.Name;
            if( name == null || name.Length == 0 )
                return String.Empty;
            while( obj.Parent != null ) {
                obj = obj.Parent;
                if( obj.Name != null && obj.Name.Length > 0 )
                    name = obj.Name + "." + name;
                else {
                    while( obj.Parent != null && !(obj is UmlProject) )
                        obj = obj.Parent;
                    if( obj != null )
                        name = ((UmlProject)obj).uid + "/" + name;

                    break;
                }
            }
            return name;
        }
예제 #30
0
 public override void Visit( Visitor v, UmlObject parent )
 {
     foreach( UmlProject proj in projects )
         proj.Visit( v, this );
     foreach( UmlProject proj in dllprojs )
         proj.Visit( v, this );
 }
예제 #31
0
 public override void Visit( Visitor v, UmlObject parent )
 {
     if( SubNamespaces != null )
         foreach( UmlNamespace o in SubNamespaces )
             o.Visit( v, this );
     if( Types != null )
         foreach( UmlType o in Types )
             o.Visit( v, this );
     v( this, parent );
 }
예제 #32
0
        void TreeMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            TreeNode node = (sender as TreeView).GetNodeAt( e.X, e.Y);
            if( node == null )
                return;
            object obj = ProjectTree.GetNodeObject( node );

            dragbox = Rectangle.Empty;
            if( (e.Button & MouseButtons.Left) == MouseButtons.Left ) {

                if( obj is UMLDes.GUI.View ) {
                    if( e.Clicks == 2 ) {
                        UMLDes.GUI.View v = obj as UMLDes.GUI.View;
                        SelectView( v, true );
                    }

                } else if( !(obj is UmlDesignerSolution) ) {
                    Size dragSize = SystemInformation.DragSize;
                    dragbox = new Rectangle(new Point(e.X - (dragSize.Width /2), e.Y - (dragSize.Height /2)), dragSize);
                    dragobject = obj as UmlObject;
                }
            } else if( (e.Button & MouseButtons.Right) == MouseButtons.Right ) {
                ProjectTree.SelectedNode = node;
                if( obj != null )
                    TryDropDownMenu( e.X, e.Y, obj, node );
            }
        }
예제 #33
0
 public virtual void Visit( Visitor v, UmlObject parent )
 {
 }
예제 #34
0
        // Drag-n-drop functions
        public override void StartDrag( UmlObject elem )
        {
            dropobj = elem;
            dropitem = GuiElementFactory.CreateElement( elem );

            if( dropitem != null ) {
                System.Diagnostics.Debug.Assert( dropitem is IMoveable && dropitem is IRemoveable, "wrong element created" );
                dropitem.parent = parent;
                if( dropitem is INeedRefresh )
                    parent.RefreshObject( (INeedRefresh)dropitem );
                action = MouseAction.Drag;
            } else
                action = MouseAction.None;
        }
예제 #35
0
 public abstract void StartDrag( UmlObject elem );