Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12246


Ignore:
Timestamp:
03/24/15 11:07:36 (10 years ago)
Author:
pfleck
Message:

#2025 Added a Priority for the CreatableAttribute to manually define an ordering for the NewItemDialog.

Location:
branches/NewItemDialog
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/NewItemDialog/HeuristicLab.Core/3.3/Attributes/CreatableAttribute.cs

    r12012 r12246  
    3636    }
    3737
     38    public int Priority { get; set; }
     39
     40
    3841    public CreatableAttribute() {
    3942      Category = "Other Items";
     43      Priority = int.MaxValue;
    4044    }
    4145    public CreatableAttribute(string category)
     
    5357      else return null;
    5458    }
     59
     60    public static int GetPriority(Type type) {
     61      var attribs = type.GetCustomAttributes(typeof(CreatableAttribute), false);
     62      if (attribs.Length > 0) return ((CreatableAttribute)attribs[0]).Priority;
     63      else return int.MaxValue;
     64    }
    5565  }
    5666}
  • branches/NewItemDialog/HeuristicLab.Optimizer/3.3/NewItemDialog.cs

    r12239 r12246  
    6767        let category = CreatableAttribute.GetCategory(type)
    6868        let name = ItemAttribute.GetName(type)
     69        let priority = CreatableAttribute.GetPriority(type)
    6970        let version = ItemAttribute.GetVersion(type)
    7071        where CreatableAttribute.IsCreatable(type)
    71         orderby category, name, version ascending
     72        orderby category, priority, name, version ascending
    7273        group type by category into categoryGroup
    7374        select categoryGroup;
Note: See TracChangeset for help on using the changeset viewer.