1 package org
.argeo
.slc
.client
.ui
.commands
;
4 * Copyright (C) 2007-2012 Mathieu Baudier
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import java
.util
.Iterator
;
21 import org
.argeo
.slc
.client
.ui
.ClientUiPlugin
;
22 import org
.argeo
.slc
.client
.ui
.model
.ResultParent
;
23 import org
.argeo
.slc
.client
.ui
.views
.JcrResultTreeView
;
24 import org
.eclipse
.core
.commands
.AbstractHandler
;
25 import org
.eclipse
.core
.commands
.ExecutionEvent
;
26 import org
.eclipse
.core
.commands
.ExecutionException
;
27 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
28 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
31 * Force refresh the ResultTreeView. This command is only intended to be called
32 * by either the toolbar menu of the view or by the popup menu. Refresh due to
33 * data changes must be triggered by Observers
35 public class RefreshJcrResultTreeView
extends AbstractHandler
{
36 public final static String ID
= ClientUiPlugin
.ID
37 + ".refreshJcrResultTreeView";
38 public final static String PARAM_REFRESH_TYPE
= ClientUiPlugin
.ID
39 + ".param.refreshType";
40 public final static String PARAM_REFRESH_TYPE_FULL
= "fullRefresh";
42 public Object
execute(final ExecutionEvent event
) throws ExecutionException
{
43 String refreshType
= event
.getParameter(PARAM_REFRESH_TYPE
);
44 JcrResultTreeView view
= (JcrResultTreeView
) HandlerUtil
45 .getActiveWorkbenchWindow(event
).getActivePage()
48 // force full refresh without preserving selection from the tool bar
49 if (PARAM_REFRESH_TYPE_FULL
.equals(refreshType
))
52 IStructuredSelection selection
= (IStructuredSelection
) HandlerUtil
53 .getActiveWorkbenchWindow(event
).getActivePage()
55 @SuppressWarnings("rawtypes")
56 Iterator it
= selection
.iterator();
57 while (it
.hasNext()) {
58 Object obj
= it
.next();
59 if (obj
instanceof ResultParent
) {
60 view
.refresh((ResultParent
) obj
);