Contribute CNF based TMF project handling
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / handlers / RefreshHandler.java
CommitLineData
12c155f5
FC
1/*******************************************************************************
2 * Copyright (c) 2011 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.ui.project.handlers;
14
15import org.eclipse.core.commands.AbstractHandler;
16import org.eclipse.core.commands.ExecutionEvent;
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.jface.viewers.ISelection;
19import org.eclipse.jface.viewers.TreeSelection;
20import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
21import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder;
22import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
23import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
24import org.eclipse.ui.IWorkbenchPage;
25import org.eclipse.ui.IWorkbenchPart;
26import org.eclipse.ui.IWorkbenchWindow;
27import org.eclipse.ui.PlatformUI;
28
29/**
30 * <b><u>RefreshHandler</u></b>
31 * <p>
32 * TODO: Handle multiple selections
33 */
34public class RefreshHandler extends AbstractHandler {
35
36 // ------------------------------------------------------------------------
37 // Execution
38 // ------------------------------------------------------------------------
39
40 @Override
41 public Object execute(ExecutionEvent event) throws ExecutionException {
42
43 // Check if we are closing down
44 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
45 if (window == null)
46 return null;
47
48 // Get the selection
49 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
50 IWorkbenchPart part = page.getActivePart();
51 ISelection selection = part.getSite().getSelectionProvider().getSelection();
52 if (selection instanceof TreeSelection) {
53 TreeSelection treeSelection = (TreeSelection) selection;
54 Object element = treeSelection.getFirstElement();
55 if (element instanceof TmfTraceFolder) {
56 TmfTraceFolder folder = (TmfTraceFolder) element;
57 TmfProjectElement project = (TmfProjectElement) folder.getProject();
58 project.refresh();
59 }
60 else if (element instanceof TmfExperimentFolder) {
61 TmfExperimentFolder folder = (TmfExperimentFolder) element;
62 TmfProjectElement project = (TmfProjectElement) folder.getProject();
63 project.refresh();
64 }
65 else if (element instanceof TmfExperimentElement) {
66 TmfExperimentElement folder = (TmfExperimentElement) element;
67 TmfProjectElement project = folder.getProject();
68 project.refresh();
69 }
70 }
71
72
73 return null;
74 }
75
76}
This page took 0.026702 seconds and 5 git commands to generate.