]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/commands/RefreshJcrResultTreeView.java
Fix drag and drop for multiple flows between these 2 pages.
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui / src / main / java / org / argeo / slc / client / ui / commands / RefreshJcrResultTreeView.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16 package org.argeo.slc.client.ui.commands;
17
18 /*
19 * Copyright (C) 2007-2012 Mathieu Baudier
20 *
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
24 *
25 * http://www.apache.org/licenses/LICENSE-2.0
26 *
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.
32 */
33
34 import java.util.Iterator;
35
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;
44
45 /**
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
49 */
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";
56
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()
61 .getActivePart();
62
63 // force full refresh without preserving selection from the tool bar
64 if (PARAM_REFRESH_TYPE_FULL.equals(refreshType))
65 view.refresh(null);
66 else {
67 IStructuredSelection selection = (IStructuredSelection) HandlerUtil
68 .getActiveWorkbenchWindow(event).getActivePage()
69 .getSelection();
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);
76 }
77 }
78 }
79 return null;
80 }
81 }