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
.cms
.e4
.jcr
.handlers
;
18 import java
.util
.List
;
20 import javax
.inject
.Named
;
22 import org
.argeo
.cms
.e4
.jcr
.JcrBrowserView
;
23 import org
.argeo
.cms
.ui
.jcr
.JcrBrowserUtils
;
24 import org
.argeo
.eclipse
.ui
.TreeParent
;
25 import org
.eclipse
.e4
.core
.di
.annotations
.Execute
;
26 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
27 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
28 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
;
29 import org
.eclipse
.e4
.ui
.workbench
.modeling
.ESelectionService
;
32 * Force the selected objects of the active view to be refreshed doing the
35 * <li>The model objects are recomputed</li>
36 * <li>the view is refreshed</li>
39 public class Refresh
{
42 public void execute(@Named(IServiceConstants
.ACTIVE_PART
) MPart part
, EPartService partService
,
43 ESelectionService selectionService
) {
45 JcrBrowserView view
= (JcrBrowserView
) part
.getObject();
46 List
<?
> selection
= (List
<?
>) selectionService
.getSelection();
48 if (selection
!= null && !selection
.isEmpty()) {
49 for (Object obj
: selection
)
50 if (obj
instanceof TreeParent
) {
51 TreeParent tp
= (TreeParent
) obj
;
52 JcrBrowserUtils
.forceRefreshIfNeeded(tp
);
55 } else if (view
instanceof JcrBrowserView
)
56 view
.refresh(null); // force full refresh