~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/DestroySessionHandler.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-13 21:43:22 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130513214322-6frgd9du1n0w2uo7
Tags: 1.2.1-1
* Team upload.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**********************************************************************
2
2
 * Copyright (c) 2012 Ericsson
3
 
 * 
 
3
 *
4
4
 * All rights reserved. This program and the accompanying materials are
5
5
 * made available under the terms of the Eclipse Public License v1.0 which
6
6
 * accompanies this distribution, and is available at
7
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 
 * 
9
 
 * Contributors: 
 
8
 *
 
9
 * Contributors:
10
10
 *   Bernd Hufmann - Initial API and implementation
11
11
 **********************************************************************/
12
12
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
39
39
 * <p>
40
40
 * Command handler implementation to destroy one or more trace sessions.
41
41
 * </p>
42
 
 * 
 
42
 *
43
43
 * @author Bernd Hufmann
44
44
 */
45
45
public class DestroySessionHandler extends BaseControlViewHandler {
48
48
    // Attributes
49
49
    // ------------------------------------------------------------------------
50
50
    /**
51
 
     * The list of session components the command is to be executed on. 
 
51
     * The list of session components the command is to be executed on.
52
52
     */
53
 
    private List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
54
 
    
 
53
    private final List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
 
54
 
55
55
    // ------------------------------------------------------------------------
56
56
    // Operations
57
57
    // ------------------------------------------------------------------------
69
69
        }
70
70
        // Get user confirmation
71
71
        IConfirmDialog dialog = TraceControlDialogFactory.getInstance().getConfirmDialog();
72
 
        if (!dialog.openConfirm(window.getShell(), 
73
 
                Messages.TraceControl_DestroyConfirmationTitle, 
 
72
        if (!dialog.openConfirm(window.getShell(),
 
73
                Messages.TraceControl_DestroyConfirmationTitle,
74
74
                Messages.TraceControl_DestroyConfirmationMessage)) {
75
75
 
76
76
            return null;
80
80
            @Override
81
81
            protected IStatus run(IProgressMonitor monitor) {
82
82
                try {
83
 
                    // Make a copy of the list of sessions to avoid ConcurrentModificationException when iterating 
84
 
                    // over fSessions, since fSessions is modified in another thread triggered by the tree viewer refresh 
 
83
                    // Make a copy of the list of sessions to avoid ConcurrentModificationException when iterating
 
84
                    // over fSessions, since fSessions is modified in another thread triggered by the tree viewer refresh
85
85
                    // after removing a session.
86
 
                    TraceSessionComponent[] sessions = (TraceSessionComponent[])fSessions.toArray(new TraceSessionComponent[fSessions.size()]);
 
86
                    TraceSessionComponent[] sessions = fSessions.toArray(new TraceSessionComponent[fSessions.size()]);
87
87
 
88
88
                    for (int i = 0; i < sessions.length; i++) {
89
89
                        // Destroy all selected sessions
92
92
                        sessionGroup.destroySession(session, monitor);
93
93
                    }
94
94
                } catch (ExecutionException e) {
95
 
                    return new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_DestroySessionFailure, e);
96
 
                }  
 
95
                    return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_DestroySessionFailure, e);
 
96
                }
97
97
                return Status.OK_STATUS;
98
98
            }
99
99
        };
121
121
        if (selection instanceof StructuredSelection) {
122
122
            StructuredSelection structered = ((StructuredSelection) selection);
123
123
            for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
124
 
                Object element = (Object) iterator.next();
 
124
                Object element = iterator.next();
125
125
                if (element instanceof TraceSessionComponent) {
126
126
                    // Add only TraceSessionComponents that are inactive and not destroyed
127
127
                    TraceSessionComponent session = (TraceSessionComponent) element;