**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
-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.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.CreateSessionDialog;
import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.TraceControlDialogFactory;
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;
/**
* <b><u>CreateSessionHandler</u></b>
* Command handler implementation to create a trace session.
* </p>
*/
-public class CreateSessionHandler extends AbstractHandler {
+public class CreateSessionHandler extends BaseControlViewHandler {
// ------------------------------------------------------------------------
// Attributes
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- return false;
- }
// Open dialog box for the node name and address
- ICreateSessionDialog dialog = new CreateSessionDialog(window.getShell(), fSessionGroup);
+ ICreateSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateSessionDialog();
+ dialog.setTraceSessionGroup(fSessionGroup);
if (dialog.open() != Window.OK) {
return null;
*/
@Override
public boolean isEnabled() {
- fSessionGroup = null;
-
- // 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;
- }
+ fSessionGroup = null;
// Check if the session group project is selected
ISelection selection = page.getSelection(ControlView.ID);