Creating Custom Folder Behavior
  • Updated on 09 Dec 2013
  • 4 minutes to read
  • Print
  • Dark
    Light

Creating Custom Folder Behavior

  • Print
  • Dark
    Light

Overview

New folder behaviors can be created to modify the default folder behavior. Many aspects of a folder's behavior can be modified. All the overridable methods for a folder's default behavior are listed at the end of this document. The most common overrides are highlighted as examples below.

Examples

ShowInTreeView : Overriding lets us control whether this folder type shows up in the folder tree. By default it is shown. Here is an example showing how to cause to be hidden from the tree.

 public override bool? ShowInTreeView()
{
   return false;
}

Using this override will cause the folder to show up only in the folder view of the parent folder as shown below. Even thoughNew Folder is a child ofRoot Folder it is not show in the folder tree; it appears only as part of the Folder Data whenRoot Folder is selected.
2017-02-16_121227.png

GetFolderActions : Overriding allows us to control which actions are shown on a folder. In the example below, in addition to the default action that are supplied for a folder, we have added an action to open the URL www.decisions.com .

 public override BaseActionType[] GetFolderActions(Folder folder, BaseActionType[] proposedActions, EntityActionType[] types)
{
    List<baseactiontype> actions = new List<baseactiontype>((proposedActions ?? new BaseActionType[0]));

    actions.Add(new OpenUrlAction("Open Decisions.com", "Clicking this action will open http://www.decisions.com", "http://www.decisions.com"));

    return actions.ToArray();
}</baseactiontype></baseactiontype>

With this override, the action would show up looking like the following:

2017-02-16_121340.png

CanBeSetByUser : Overriding allows us to control whether or not this folder type is allowed to be added by users via the actions menu. By default, this value is set to false . Below is example code showing how to override to equal true .

 public override bool CanBeSetByUser()
{
   return true;
}

Setting to true causes the folder type to show up in the actions menu as shown below:

2017-02-16_121741.png{height ="276" width="903"}

CanAddEntity : Overriding allows us to control what entity types are allowed to be added to this folder type. For example, you may want to create a folder type that is only allowed to contain Designer Project folders. To do this, you would write an override as follows:

 public override bool CanAddEntity(AbstractFolderEntity folderEntity)
{
   return folderEntity is Folder && (folderEntity as Folder).FolderBehaviorType == typeof(DesignerProjectFolder).FullName;
} 

CanBeRootFolder : Overriding allows us to control whether or not this folder is allowed to be a root folder. By default any folder type other than DefaultFolderBehavior are NOT allowed to be root folders. Setting this override to true will allow the folder to be a root folder. The following sample demonstrates this:

 public override bool? CanBeRootFolder()
{
   return true;
}

List of All Properties that Can be Overridden ```
public virtual bool AlwaysOpenInNewWindow { get; }
public virtual bool AuditFolderViews { get; }
public virtual bool CanBeDefaultFolder { get; }
public virtual bool CanBeFavorites { get; }
public virtual bool CanBeRecent { get; }
public virtual string FolderBehaviorName { get; }
public virtual string OverrideCreateActionName { get; }
public virtual FolderPermissionBehavior PermissionBehavior { get; }
public virtual bool RecordStateChange { get; }
public virtual bool ShowAlternateViews { get; }
public virtual string SubMenuGroupName { get; }
public virtual void AddToCache(Folder f, AbstractFolderEntity value, bool createIfNotExist = true);
public virtual void AfterBehaviorAssigned(Folder f);
public virtual void AfterDelete(AbstractFolderEntity folderEntity);
public virtual void AfterSave(AbstractFolderEntity folderEntity);
public virtual bool CanAddEntity(AbstractFolderEntity folderEntity);
public virtual bool? CanBeRootFolder();
public virtual bool CanBeSetByUser();
public virtual bool CanBeUnset();
public virtual bool CanChangeNameAndDescription();
public virtual bool CanRemoveEntity(AbstractFolderEntity folderEntity);
public virtual bool CanUserChangeDefaultPage();
public virtual void ClearFolderCache(Folder f);
public virtual void ClearFolderCache(Folder f, Type t);
public virtual void CommitAdditionalFolderData(Folder folder, DataPair[] data);
public virtual bool ContainsStructures();
public virtual DataPair[] GetAdditionalFolderViewData(Folder f);
protected ICache<ConcurrentDictionary<string, abstractentity="">> GetCache(Folder f, Type t);
protected virtual string GetCacheConfigurationNameForType(Type t);
protected virtual string GetDefaultCacheConfigurationName();
public virtual string GetDefaultPageName(Folder folder);
public virtual BaseActionType[] GetFolderActions(Folder folder, BaseActionType[] proposedActions, EntityActionType[] types);
public virtual string GetFolderEntityDescription(Folder f, string currentDescription, bool forHeader);
public virtual string GetFolderEntityName(Folder f, string currentName);
public virtual Type GetFolderExtensionDataType();
public virtual T[] GetFolderObjects(Folder f, bool includeDeleted = false, bool loadIfNotExists = true) where T : AbstractEntity;
public virtual AbstractFolderEntity[] GetFolderObjects(Folder f, Type t, bool includeDeleted = false, bool loadIfNotExists = true);
public ConcurrentDictionary<string, abstractentity=""> GetFolderObjectsDictionary(Folder f, Type t, bool createAndFetchIfDoesNotExist);
public T[] GetFolderObjectsWithExtensionType<t, extensiontype="">(Folder f, bool includeDeleted = false, bool loadIfNotExists = true) where T : AbstractEntity;
public virtual string GetFolderShortTypeName(Folder f);
public virtual TimeSpan GetLockScreenTimeout(Folder folder);
public virtual bool? GetSendEventsOnAddingToFolder();
public virtual bool? GetSendEventsOnFolderOwnedDataSave();
public virtual bool? GetSendEventsOnFolderSave();
public virtual SubMenuBehavior GetSubMenuBehavior();
public virtual ViewPageData[] GetViewPages(Folder folder);
public virtual bool IsAdditionalFolderViewDataReadOnly(Folder folder, FolderPermission currentUserPermissions);
public virtual void OnBehaviorAssigned(Folder f);
public virtual void OnFolderHidden(Folder f);
public virtual void OnFolderUnhidden(Folder f);
public virtual void OnStateChange(Folder f, string oldState, string newState);
public virtual void OnStateChangeCompleted(Folder f, string newState);
public virtual SubFolderViewData[] OrderSubFolders(SubFolderViewData[] subFolders);
public virtual IORMEntity[] ProcessExportEntities(IORMEntity[] entities);
public virtual void RemoveFromCache(Folder f, AbstractFolderEntity value, bool createIfNotExist = true);
public virtual bool ShouldAutoLockScreen(Folder folder);
public virtual bool? ShowBrowseView();
public virtual bool? ShowInTreeView();
public virtual void UpdateCacheItem(Folder f, AbstractFolderEntity value, bool createIfNotExist = true);</t,></string,>
</string,>



Was this article helpful?