import { IComp } from 'mel-common'; export interface WorkbenchApp { url: string; code: string; name: string; } export declare type AppConnection = WorkbenchApp; export interface AppCompany { id: number; name: string; } /** * the recent connection of an app */ export declare class RecentAppConnection implements IComp { element: AppConnection; constructor(element: AppConnection); compare(other: RecentAppConnection): number; } export declare class RecentAppCompany implements IComp { element: AppCompany; constructor(element: AppCompany); compare(other: RecentAppCompany): number; } /** * the recent app and connection of the workbench */ export declare class RecentWorkbenchApp implements IComp { element: WorkbenchApp; constructor(element: WorkbenchApp); compare(other: RecentWorkbenchApp): number; } /** * Generic abstract baseclass for recenthandling * A "Recent" has an array of recently used comparable instances of Recents. * It's elements contain information of the type T. * It is able to store and restore itself with a unique key, the cookieName * Derivied classes can contain other recents with a different elementtype T * Derivied classes: * - RecentAppCompanies * - RecentAppConnections (contains RecentAppCompanies) * - RecentWorkbenchApps * Abstract methods: * getRecentInstance(i:T): return a recent of type T * Public methods: * get lastRecentElement: returns the top of the recent-stack * set lastRecentElement: set the item on top the stack * get lastRecent: the recentliy used recent * set lastRecent: set a recent as recently used * get elements: the elements of the recent * get otherRecents : all recents except the lastRecent * get otherElements : all element except the lastRecent element * adjust: adjust the elements with these of another recent. the result is stored * */ declare abstract class Recent, T> { protected elementType: Function; protected key: string; protected abstract getRecentInstance(e: T): R; constructor(elementType: Function, key: string); protected get cookieName(): string; protected recents: R[]; get elements(): T[]; get lastRecentElement(): T | undefined; set lastRecentElement(newElement: T | undefined); get lastRecent(): R | undefined; /** * sets the recent at the index 0 */ set lastRecent(recent: R | undefined); /** * returns the recents from index 1.. */ get otherRecents(): R[]; get otherElements(): T[]; /** * Adjusts the recentlist with another. The result is a recentlist which contains only the members of the itemsToAdjust * in the order of the existing itemlist * @param recentsToAdjust */ adjust(recentsToAdjust: R[]): void; protected store(): void; protected restore(): R[]; /** * adds a new item at index 0 * @param newRecent */ protected add(newRecent: R): number; } /** * Stores the recently used compnies of an app */ export declare class RecentAppCompanies extends Recent { protected getRecentInstance(e: AppCompany): RecentAppCompany; constructor(appCode: string); } /** * Stores the recently used urls to the app-server of an application with it's * last recently used companies */ export declare class RecentAppConnections extends Recent { protected getRecentInstance(e: AppConnection): RecentAppConnection; recentAppCompanies: RecentAppCompanies; constructor(appCode: string); } /** * Stores the recent app-code (client-name), the corresponding Applicationname and url to the appserver * Only for the workbench to handle more than one App */ export declare class RecentWorkbenchApps extends Recent { protected getRecentInstance(o: WorkbenchApp): RecentWorkbenchApp; constructor(key: string); } export declare var MelRecents: RecentAppConnections | RecentWorkbenchApps; export declare function initRecents(recentType: Function, key: string): RecentAppConnections | RecentWorkbenchApps; export {};