import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IConfirmDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
* Command handler implementation to destroy one or more trace sessions.
* </p>
*/
-public class DestroySessionHandler extends AbstractHandler {
+public class DestroySessionHandler extends BaseControlViewHandler {
// ------------------------------------------------------------------------
// Attributes
return false;
}
// Get user confirmation
- if (!MessageDialog.openConfirm(window.getShell(),
+ IConfirmDialog dialog = TraceControlDialogFactory.getInstance().getConfirmDialog();
+ if (!dialog.openConfirm(window.getShell(),
Messages.TraceControl_DestroyConfirmationTitle,
Messages.TraceControl_DestroyConfirmationMessage)) {
return null;
-
}
Job job = new Job(Messages.TraceControl_DestroySessionJob) {
*/
@Override
public boolean isEnabled() {
- fSessions.clear();
-
- // Check if we are closing down
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- return false;
- }
-
- // Check if we are in the Project View
- IWorkbenchPage page = window.getActivePage();
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
return false;
}
-
- IWorkbenchPart part = page.getActivePart();
- if (!(part instanceof ControlView)) {
- return false;
- }
+ fSessions.clear();
// Check if one or more session are selected
ISelection selection = page.getSelection(ControlView.ID);