protected void registerProviders() { Log.i(this.getClass().getSimpleName(), "register proviers ......."); DocumentProvider docProvider = getAutomationClient().getDocumentProvider(); // register a query String providerName1 = "Simple select"; if (!docProvider.isRegistred(providerName1)) { String query = "select * from Document where ecm:mixinType != \"HiddenInNavigation\" AND ecm:isCheckedInVersion = 0 AND ecm:currentLifeCycleState != \"deleted\" order by dc:modified DESC"; docProvider.registerNamedProvider( getNuxeoSession(), providerName1, query, 10, false, false, null); } // register an operation String providerName2 = "Get Worklist operation"; if (!docProvider.isRegistred(providerName2)) { // create the fetch operation OperationRequest getWorklistOperation = getNuxeoSession().newRequest("Seam.FetchFromWorklist"); // define what properties are needed getWorklistOperation.setHeader("X-NXDocumentProperties", "common,dublincore"); // register provider from OperationRequest docProvider.registerNamedProvider( providerName2, getWorklistOperation, null, false, false, null); } // register a documentList String providerName3 = "My Documents"; if (!docProvider.isRegistred(providerName3)) { String query2 = "SELECT * FROM Document WHERE dc:contributors = ?"; LazyUpdatableDocumentsList docList = new LazyUpdatableDocumentsListImpl( getNuxeoSession(), query2, new String[] {"Administrator"}, null, null, 10); docList.setName(providerName3); docProvider.registerNamedProvider(docList, false); } // register a query String providerName4 = "mypictures"; if (!docProvider.isRegistred(providerName4)) { String query = "select * from Picture"; docProvider.registerNamedProvider( getNuxeoSession(), providerName4, query, 10, false, false, "image"); } // register a query String providerName5 = "mynotes"; if (!docProvider.isRegistred(providerName5)) { String query = "select * from Note"; docProvider.registerNamedProvider( getNuxeoSession(), providerName5, query, 10, false, false, "text"); } }
@Override public boolean isReady() { if (super.isReady()) { if (documentsList != null) { return documentsList.getLoadingPagesCount() == 0 && documentsList.getLoadedPageCount() > 0; } else { return false; } } else { return false; } }
protected void doRefresh() { if (documentsList != null) { documentsList.refreshAll(); } else { runAsyncDataRetrieval(); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (v.getId() == listView.getId()) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Document doc = documentsList.getDocument(info.position); menu.setHeaderTitle(doc.getTitle()); populateContextMenu(doc, menu); } super.onCreateContextMenu(menu, v, menuInfo); }
@Override protected void onListItemClicked(int listItemPosition) { if (getEditActivityClass() != null) { Document doc = documentsList.getDocument(listItemPosition); startActivity( new Intent(this, getEditActivityClass()) .putExtra(BaseDocumentLayoutActivity.DOCUMENT, doc) .putExtra(BaseDocumentLayoutActivity.MODE, LayoutMode.VIEW)); } }
protected Document getContextMenuDocument(int selectedPosition) { return documentsList.getDocument(selectedPosition); }
protected void onDocumentUpdate(Document editedDocument) { documentsList.updateDocument(editedDocument); }
protected void onDocumentCreate(Document newDocument) { documentsList.createDocument(newDocument); }