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