]> git.argeo.org Git - lgpl/argeo-commons.git/blob - base/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/commands/Refresh.java
Refactor JCR utils and home usage
[lgpl/argeo-commons.git] / base / runtime / org.argeo.eclipse.ui.jcr / src / main / java / org / argeo / eclipse / ui / jcr / commands / Refresh.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.eclipse.ui.jcr.commands;
17
18 import java.util.Iterator;
19
20 import org.argeo.eclipse.ui.jcr.views.AbstractJcrBrowser;
21 import org.eclipse.core.commands.AbstractHandler;
22 import org.eclipse.core.commands.ExecutionEvent;
23 import org.eclipse.core.commands.ExecutionException;
24 import org.eclipse.jface.viewers.ISelection;
25 import org.eclipse.jface.viewers.IStructuredSelection;
26 import org.eclipse.ui.handlers.HandlerUtil;
27
28 /**
29 * Call the refresh method of the active AbstractJcrBrowser instance.
30 *
31 * Warning: this method only refreshes the viewer, if the model is "stale", e.g.
32 * if some changes in the underlying data have not yet been propagated to the
33 * model, the view will not display up-to-date information.
34 */
35 @Deprecated
36 public class Refresh extends AbstractHandler {
37
38 public Object execute(ExecutionEvent event) throws ExecutionException {
39 ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
40 .getActivePage().getSelection();
41 AbstractJcrBrowser view = (AbstractJcrBrowser) HandlerUtil
42 .getActiveWorkbenchWindow(event).getActivePage()
43 .findView(HandlerUtil.getActivePartId(event));
44 if (selection != null && selection instanceof IStructuredSelection) {
45 Iterator<?> it = ((IStructuredSelection) selection).iterator();
46 while (it.hasNext()) {
47 Object obj = it.next();
48 view.refresh(obj);
49 }
50 }
51 return null;
52 }
53 }