]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - Refresh.java
4d5e57761caf97eb69f476a44ee51c505c13deb4
2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.jcr
.ui
.explorer
.commands
;
18 import java
.util
.Iterator
;
20 import org
.argeo
.eclipse
.ui
.TreeParent
;
21 import org
.argeo
.eclipse
.ui
.jcr
.views
.AbstractJcrBrowser
;
22 import org
.argeo
.jcr
.ui
.explorer
.utils
.JcrUiUtils
;
23 import org
.eclipse
.core
.commands
.AbstractHandler
;
24 import org
.eclipse
.core
.commands
.ExecutionEvent
;
25 import org
.eclipse
.core
.commands
.ExecutionException
;
26 import org
.eclipse
.jface
.viewers
.ISelection
;
27 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
28 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
31 * Force the selected objects of the active view to be refreshed doing the
34 * <li>The model objects are recomputed</li>
35 * <li>the view is refreshed</li>
38 public class Refresh
extends AbstractHandler
{
40 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
41 ISelection selection
= HandlerUtil
.getActiveWorkbenchWindow(event
)
42 .getActivePage().getSelection();
43 AbstractJcrBrowser view
= (AbstractJcrBrowser
) HandlerUtil
44 .getActiveWorkbenchWindow(event
).getActivePage()
45 .findView(HandlerUtil
.getActivePartId(event
));
46 if (selection
!= null && selection
instanceof IStructuredSelection
) {
47 Iterator
<?
> it
= ((IStructuredSelection
) selection
).iterator();
48 while (it
.hasNext()) {
49 Object obj
= it
.next();
50 if (obj
instanceof TreeParent
) {
51 TreeParent tp
= (TreeParent
) obj
;
52 JcrUiUtils
.forceRefreshIfNeeded(tp
);