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
.resource
.ImageDescriptor
;
43 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
44 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
47 * Force refresh the ResultTreeView. This command is only intended to be called
48 * by either the toolbar menu of the view or by the popup menu. Refresh due to
49 * data changes must be triggered by Observers
51 public class RefreshJcrResultTreeView
extends AbstractHandler
{
52 public final static String ID
= ClientUiPlugin
.ID
53 + ".refreshJcrResultTreeView";
54 public final static String PARAM_REFRESH_TYPE
= ClientUiPlugin
.ID
55 + ".param.refreshType";
56 public final static String PARAM_REFRESH_TYPE_FULL
= "fullRefresh";
57 public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR
= ClientUiPlugin
58 .getImageDescriptor("icons/refresh.png");
59 public final static String DEFAULT_LABEL
= "Refresh selected";
61 public Object
execute(final ExecutionEvent event
) throws ExecutionException
{
62 String refreshType
= event
.getParameter(PARAM_REFRESH_TYPE
);
63 JcrResultTreeView view
= (JcrResultTreeView
) HandlerUtil
64 .getActiveWorkbenchWindow(event
).getActivePage()
67 // force full refresh without preserving selection from the tool bar
68 if (PARAM_REFRESH_TYPE_FULL
.equals(refreshType
))
71 IStructuredSelection selection
= (IStructuredSelection
) HandlerUtil
72 .getActiveWorkbenchWindow(event
).getActivePage()
74 @SuppressWarnings("rawtypes")
75 Iterator it
= selection
.iterator();
76 while (it
.hasNext()) {
77 Object obj
= it
.next();
78 if (obj
instanceof ResultParent
) {
79 view
.refresh((ResultParent
) obj
);