Today we have a question from pibou, who asks how he can refresh the UI using content automation in Studio.
There is indeed a Refresh UI operation, but what it does is invalidate the different query caches. This will not empty the selected documents list, for instance. And that is just what pibou needs. Unfortunately we have no operation available for this by default on 5.5. So here's a workaround, until the operation is available for 5.6.

Clear selected documents list operation


This part is simple. You need Nuxeo IDE with a SDK setup. Create a new project or use an existing one, and run the operation wizard.

Here's what my wizard looks like:
Clear Selected Documents operation wizard

And here's the code of my operation:

[java]
@Operation(id = ClearSelectedDocuments.ID, category = Constants.CAT_UI, requires = Constants.SEAM_CONTEXT, label = "Clear Selected Documents", description = "Clear the default list of selected documents")
public class ClearSelectedDocuments {

public static final String ID = "Seam.ClearSelectedDocuments";

@OperationMethod
public void run() {
        OperationHelper.getDocumentListManager().resetWorkingList(
            DocumentsListsManager.CURRENT_DOCUMENT_SELECTION);
}

}
[/java]

The operationHelper can give you access to some useful Seam components. Here, it gives us the DocumentListManager, which handles the different selection lists like the clipboard, the working list or the selected documents.

Now we need to make Studio aware of that operation. If you use Nuxeo IDE and have configured your Studio account, it's dead easy. When you're on the Nuxeo Studio tab, there's an 'Export operations' button. It will first ask you to select which projects you want to scan. On the same screen, you can select the Studio project where you want to export the operations, if you have many. Click on next and you get the list of operations, it found. Select the one one you need and simply click on finish. That's it, your operation is available in your Studio project.

What it does under the hood is simply generate a Json signature of the operation and paste it on the Studio operation registry:
Studio operations registry

So if you have other questions about Studio and operations, ask them on answers.nuxeo.com.