Item

From MightyWiki

Jump to: navigation, search

Items are the most fundamental objects that make up MightyBox, like little particles these objects travel around the core from one element to another, untill eventually end up in the gui. MBItem is the root class of subjects and actions classes hierarchy. Every Subject and Action has MBItem as a superclass.

In abstract, Items are used to describe collection of options available for the user to choose from in the Command Panel. Item Sources are responsible for providing collections of item for the engine, and Action Providers are responsible for providing sets of actions to deploy on those subjects.

Item Members

A single item encapsulate basic properties

Property Type Description
Id String This is a unique string identifier given to the item by the engine. It is used to refer to items in configuration files, and in the core itself, and meanwhile retain persistence, and prevent ambiguousness when 2 items share the same title etc.
Title String A short caption that should describe the item meaning. This is also the text that will appear in the gui, and more importantly the string used for matching the user query during the filtering process in the engine.
Description String A short description for the item. May also be used for matching the user query.
Icon Image An image that stands for an item by signifying or representing it. It is displayed to the user near the item title and description. It is very recommended to attach an icon for each item for it is considered a great user interface, and eye candy.
Children List Items can contain children, and by allowing this, enable features like sub menues or file system browsing. The user can navigate into an item children, and up an item ansecctors using the arrow keys.
Match Match Represents results from a regular expression match. This property is assigned by the engine when the item goes through it. In case an item match a user query, the MBEngine attaches theMatch object to it on its way to the UI. and the ui can use this property to underline the match groups.
ResolvedItem Item This property is used when this item represents a proxy item, to return the proxy item. The ResolvedItem will be used when executing an action.

Example: "Current Selection" proxy, will return a textItem as a resolvedObject. Returns "this" by default, unless overridden

Handler MBObjectHandler An instance of MBObjectHandler is responsible to provide services like loading item's children or item's parent. if Handler is null, default values will be returned by MBItem.Children and other properties. A developer can also choose not to use an ObjectHandler, and instead override properties like Children/Parent and functions like loadChildren/hasChildren. This is only a developer choice based on desired architecture. If you want to delegate these tasks to a different class other than MBItem, use handlers.
Personal tools