/**********************************************************************
* Copyright (c) 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
- * <b><u>ChangeSessionStateHandler</u></b>
* <p>
* Abstract command handler implementation to start or stop one or more trace sessions.
* </p>
+ *
+ * @author Bernd Hufmann
*/
abstract public class ChangeSessionStateHandler extends BaseControlViewHandler {
// Attributes
// ------------------------------------------------------------------------
/**
- * The list of session components the command is to be executed on.
+ * The list of session components the command is to be executed on.
*/
protected List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
* @return new required state.
*/
abstract TraceSessionState getNewState();
-
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
-
+
/**
- * Performs the state change on given session.
- * @param session - a session which state is to be changed
- * @param monitor - a progress monitor
+ * Performs the state change on given session.
+ *
+ * @param session
+ * - a session which state is to be changed
+ * @param monitor
+ * - a progress monitor
+ * @throws ExecutionException
+ * If the command fails
*/
abstract public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException;
fLock.lock();
try {
-
+
final List<TraceSessionComponent> sessions = new ArrayList<TraceSessionComponent>();
sessions.addAll(fSessions);
for (Iterator<TraceSessionComponent> iterator = sessions.iterator(); iterator.hasNext();) {
// Start all selected sessions
- TraceSessionComponent session = (TraceSessionComponent) iterator.next();
+ TraceSessionComponent session = iterator.next();
changeState(session, monitor);
// Set Session state
session.fireComponentChanged(session);
}
} catch (ExecutionException e) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ChangeSessionStateFailure, e);
- }
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ChangeSessionStateFailure, e);
+ }
return Status.OK_STATUS;
}
};
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
+ Object element = iterator.next();
if (element instanceof TraceSessionComponent) {
// Add only TraceSessionComponents that are inactive and not destroyed
TraceSessionComponent session = (TraceSessionComponent) element;