text: sap.ui.define([
  	"sap/ui/model/json/JSONModel",
  	"sap/ui/core/mvc/Controller",
  	"sap/ui/model/Filter",
  	"sap/ui/model/FilterOperator",
  	'sap/ui/model/Sorter',
  	'sap/m/MessageBox'
  ], function (JSONModel, Controller, Filter, FilterOperator, Sorter, MessageBox) {
  	"use strict";
  
  	return Controller.extend("demo.controller.Master", {
  		
  		onInit: function () {
  			this.oRouter = this.getOwnerComponent().getRouter();
  			this._bDescendingSort = false;
  		},
  		
  		onListItemPress: function (oEvent) {
  			var oNextUIState = this.getOwnerComponent().getHelper().getNextUIState(1),
  				tablePath = oEvent.getSource().getBindingContext("table_metadata").getPath(),
  				table = tablePath.split("/").slice(-1).pop();
  
  			this.oRouter.navTo("detail", {layout: oNextUIState.layout, tableIndex: table});
  		},
  		
  		onSearch: function (oEvent) {
  			var oTableSearchState = [],
  				sQuery = oEvent.getParameter("query");
  
  			if (sQuery && sQuery.length > 0) {
  				oTableSearchState = [new Filter("name", FilterOperator.Contains, sQuery)];
  			}
  
  			this.getView().byId("tablesTable").getBinding("items").filter(oTableSearchState, "Application");
  		},
  
  		onSort: function (oEvent) {
  			this._bDescendingSort = !this._bDescendingSort;
  			var oView = this.getView(),
  				oTable = oView.byId("tablesTable"),
  				oBinding = oTable.getBinding("items"),
  				oSorter = new Sorter("name", this._bDescendingSort);
  
  			oBinding.sort(oSorter);
  		}
  	});
  }, true);