import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.AddContextDialogStub;
-import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateChannelDialogStub;
+import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableChannelDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateSessionDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.DestroyConfirmDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableEventsDialogStub;
fProxy.setScenario(SCEN_SCENARIO3_TEST);
// ------------------------------------------------------------------------
- // Create channel on session
+ // Enable channel on session
// ------------------------------------------------------------------------
- CreateChannelDialogStub channelStub = new CreateChannelDialogStub();
+ EnableChannelDialogStub channelStub = new EnableChannelDialogStub();
channelStub.setIsKernel(true);
- TraceControlDialogFactory.getInstance().setCreateChannelDialog(channelStub);
+ TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub);
- fFacility.executeCommand(session, "createChannelOnSession");
+ fFacility.executeCommand(session, "enableChannelOnSession");
// Verify that Kernel domain was created
ITraceControlComponent[] domains = session.getChildren();
info.setReadTimer(200);
channelStub.setChannelInfo(info);
- fFacility.executeCommand(domains[0], "createChannelOnDomain");
+ fFacility.executeCommand(domains[0], "enableChannelOnDomain");
// Get Kernel domain component instance
domains = session.getChildren();
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateChannelDialogStub;
+import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableChannelDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateSessionDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.DestroyConfirmDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.GetEventInfoDialogStub;
assertEquals(TraceSessionState.INACTIVE, session.getSessionState());
// ------------------------------------------------------------------------
- // Create Channel on UST global domain
+ // Enable Channel on UST global domain
// ------------------------------------------------------------------------
fProxy.setScenario(SCEN_SCENARIO2_TEST);
- CreateChannelDialogStub channelDialogStub = new CreateChannelDialogStub();
+ EnableChannelDialogStub channelDialogStub = new EnableChannelDialogStub();
channelDialogStub.setIsKernel(false);
channelDialogStub.getChannelInfo().setOverwriteMode(false);
channelDialogStub.getChannelInfo().setSwitchTimer(200);
channelDialogStub.getChannelInfo().setReadTimer(100);
channelDialogStub.getChannelInfo().setNumberOfSubBuffers(2);
- TraceControlDialogFactory.getInstance().setCreateChannelDialog(channelDialogStub);
+ TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelDialogStub);
- fFacility.executeCommand(session, "createChannelOnSession");
+ fFacility.executeCommand(session, "enableChannelOnSession");
// Verify that UST domain was created
ITraceControlComponent[] domains = session.getChildren();
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateChannelDialogStub;
+import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableChannelDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.CreateSessionDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.DestroyConfirmDialogStub;
import org.eclipse.linuxtools.internal.lttng2.stubs.dialogs.EnableEventsDialogStub;
// ------------------------------------------------------------------------
// Enable default channel on created session above
// ------------------------------------------------------------------------
- CreateChannelDialogStub channelStub = new CreateChannelDialogStub();
+ EnableChannelDialogStub channelStub = new EnableChannelDialogStub();
channelStub.setIsKernel(false);
- TraceControlDialogFactory.getInstance().setCreateChannelDialog(channelStub);
+ TraceControlDialogFactory.getInstance().setEnableChannelDialog(channelStub);
- fFacility.executeCommand(session, "createChannelOnSession");
+ fFacility.executeCommand(session, "enableChannelOnSession");
// Verify that Kernel domain was created
ITraceControlComponent[] domains = session.getChildren();
info.setReadTimer(200);
channelStub.setChannelInfo(info);
- fFacility.executeCommand(domains[0], "createChannelOnDomain");
+ fFacility.executeCommand(domains[0], "enableChannelOnDomain");
// Get Kernel domain component instance
domains = session.getChildren();
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng2.stubs.dialogs;
-
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
-
-/**
- * Create channel dialog stub implementation.
- */
-public class CreateChannelDialogStub implements ICreateChannelDialog {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private TraceDomainComponent fDomain;
- private ChannelInfo fChannelInfo;
- private boolean fIsKernel;
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
- public CreateChannelDialogStub() {
- fChannelInfo = new ChannelInfo("mychannel"); //$NON-NLS-1$
- fChannelInfo.setNumberOfSubBuffers(4);
- fChannelInfo.setOverwriteMode(true);
- fChannelInfo.setReadTimer(200);
- fChannelInfo.setSwitchTimer(100);
- fChannelInfo.setSubBufferSize(16384);
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- public void setIsKernel(boolean isKernel) {
- fIsKernel = isKernel;
- }
-
- @Override
- public IChannelInfo getChannelInfo() {
- return fChannelInfo;
- }
-
- @Override
- public void setDomainComponent(TraceDomainComponent domain) {
- fDomain = domain;
- if (fDomain != null) {
- fIsKernel = fDomain.isKernel();
- }
- }
-
- @Override
- public int open() {
- return 0;
- }
-
- @Override
- public boolean isKernel() {
- return fIsKernel;
- }
-
- public void setChannelInfo(ChannelInfo info) {
- fChannelInfo = info;
- }
-}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.stubs.dialogs;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableChannelDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * Create channel dialog stub implementation.
+ */
+public class EnableChannelDialogStub implements IEnableChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ private TraceDomainComponent fDomain;
+ private ChannelInfo fChannelInfo;
+ private boolean fIsKernel;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+ public EnableChannelDialogStub() {
+ fChannelInfo = new ChannelInfo("mychannel"); //$NON-NLS-1$
+ fChannelInfo.setNumberOfSubBuffers(4);
+ fChannelInfo.setOverwriteMode(true);
+ fChannelInfo.setReadTimer(200);
+ fChannelInfo.setSwitchTimer(100);
+ fChannelInfo.setSubBufferSize(16384);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ public void setIsKernel(boolean isKernel) {
+ fIsKernel = isKernel;
+ }
+
+ @Override
+ public IChannelInfo getChannelInfo() {
+ return fChannelInfo;
+ }
+
+ @Override
+ public void setDomainComponent(TraceDomainComponent domain) {
+ fDomain = domain;
+ if (fDomain != null) {
+ fIsKernel = fDomain.isKernel();
+ }
+ }
+
+ @Override
+ public int open() {
+ return 0;
+ }
+
+ @Override
+ public boolean isKernel() {
+ return fIsKernel;
+ }
+
+ public void setChannelInfo(ChannelInfo info) {
+ fChannelInfo = info;
+ }
+}
\ No newline at end of file
commands.control.destroy.session=Destroy Session...
commands.control.destroy.session.description=Destroy a Trace Session
-commands.control.create.channel=Create Channel...
-commands.control.create.channel.description=Create a Trace Channel
+commands.control.enable.channelOnSession=Enable Channel...
+commands.control.enable.channelOnSession.description=Enable a Trace Channel
+
+commands.control.enable.channelOnDomain=Enable Channel...
+commands.control.enable.channelOnDomain.description=Enable a Trace Channel
commands.control.enable.channel=Enable Channel
commands.control.enable.channel.description=Enable a Trace Channel
</command>
<command
categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
- description="%commands.control.create.channel.description"
- id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnSession"
- name="%commands.control.create.channel">
+ description="%commands.control.enable.channelOnSession.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnSession"
+ name="%commands.control.enable.channelOnSession">
</command>
<command
categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
- description="%commands.control.create.channel.description"
- id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnDomain"
- name="%commands.control.create.channel">
+ description="%commands.control.enable.channelOnDomain.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnDomain"
+ name="%commands.control.enable.channelOnDomain">
</command>
<command
categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
visible="true">
</separator>
<command
- commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnSession"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnSession"
icon="icons/elcl16/add_button.gif"
- label="%commands.control.create.channel"
+ label="%commands.control.enable.channelOnSession"
style="push">
<visibleWhen
checkEnabled="false">
</command>
<command
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableEventOnSession"
- icon="icons/elcl16/enable.gif"
+ icon="icons/obj16/event_enabled.gif"
label="%commands.control.enable.eventOnDomain"
style="push">
<visibleWhen
</visibleWhen>
</command>
<command
- commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnDomain"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnDomain"
icon="icons/elcl16/add_button.gif"
- label="%commands.control.create.channel"
+ label="%commands.control.enable.channelOnDomain"
style="push">
<visibleWhen
checkEnabled="false">
</command>
<command
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableEventOnDomain"
- icon="icons/elcl16/enable.gif"
+ icon="icons/elcl16/enable_event.gif"
label="%commands.control.enable.eventOnDomain"
style="push">
<visibleWhen
<command
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.assign.event"
- icon="icons/elcl16/enable.gif"
+ icon="icons/elcl16/enable_event.gif"
label="%commands.control.assign.event"
style="push">
<visibleWhen
<command
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableEvent"
- icon="icons/elcl16/enable.gif"
+ icon="icons/elcl16/enable_event.gif"
label="%commands.control.enable.event"
style="push">
<visibleWhen
<command
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.disableEvent"
- icon="icons/elcl16/disable.gif"
+ icon="icons/elcl16/disable_event.gif"
label="%commands.control.disable.event"
style="push">
<visibleWhen
</command>
<command
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableEventOnChannel"
- icon="icons/elcl16/enable.gif"
+ icon="icons/elcl16/enable_event.gif"
label="%commands.control.enable.eventOnChannel"
style="push">
<visibleWhen
</activeWhen>
</handler>
<handler
- class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CreateChannelOnSessionHandler"
- commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnSession">
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableChannelOnSessionHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnSession">
<activeWhen>
<with
variable="selection">
</activeWhen>
</handler>
<handler
- class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CreateChannelOnDomainHandler"
- commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createChannelOnDomain">
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableChannelOnDomainHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnDomain">
<activeWhen>
<with
variable="selection">
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * <b><u>CreateChannelDialog</u></b>
- * <p>
- * Dialog box for collecting channel creation information.
- * </p>
- */
-public class CreateChannelDialog extends Dialog implements ICreateChannelDialog {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
- /**
- * The icon file for this dialog box.
- */
- public static final String ENABLE_CHANNEL_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /**
- * The dialog composite.
- */
- private Composite fDialogComposite = null;
- /**
- * The text widget for the channel name
- */
- private Text fChannelNameText = null;
- /**
- * The discard mode of the channel.
- */
- private Button fDiscardModeButton = null;
- /**
- * The overwrite mode of the channel.
- */
- private Button fOverwriteModeButton = null;
- /**
- * The sub-buffer size of the channel.
- */
- private Text fSubBufferSizeText = null;
- /**
- * The number of sub-buffers of the channel.
- */
- private Text fNumberOfSubBuffersText = null;
- /**
- * The switch timer interval of the channel.
- */
- private Text fSwitchTimerText = null;
- /**
- * The read timer interval of the channel.
- */
- private Text fReadTimerText = null;
- /**
- * Group composite for domain selection.
- */
- private Group fDomainGroup = null;
- /**
- * Radio button for selecting kernel domain.
- */
- private Button fKernelButton = null;
- /**
- * Radio button for selecting UST domain.
- */
- private Button fUstButton = null;
- /**
- * The parent domain component where the channel node should be added.
- * Null in case of creation on session level.
- */
- private TraceDomainComponent fDomain = null;
- /**
- * Common verify listener for numeric text input.
- */
- private VerifyListener fVerifyListener = null;
- /**
- * Output channel information.
- */
- private IChannelInfo fChannelInfo = null;
- /**
- * Output domain information. True in case of Kernel domain. False for UST.
- */
- private boolean fIsKernel;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- * @param shell - a shell for the display of the dialog
- */
- public CreateChannelDialog(Shell shell) {
- super(shell);
- fIsKernel = true;
-
- // Common verify listener
- fVerifyListener = new VerifyListener() {
- @Override
- public void verifyText(VerifyEvent e) {
- // only numbers are allowed.
- e.doit = e.text.matches("[0-9]*"); //$NON-NLS-1$
- }
- };
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#getChannelInfo()
- */
- @Override
- public IChannelInfo getChannelInfo() {
- return fChannelInfo;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#setDomainComponent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent)
- */
- @Override
- public void setDomainComponent(TraceDomainComponent domain) {
- fDomain = domain;
- if (fDomain != null) {
- fIsKernel = fDomain.isKernel();
- } else {
- fIsKernel = true;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#isKernel()
- */
- @Override
- public boolean isKernel() {
- return fIsKernel;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(Messages.TraceControl_EnableChannelDialogTitle);
- newShell.setImage(Activator.getDefault().loadIcon(ENABLE_CHANNEL_ICON_FILE));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
-
- // Main dialog panel
- fDialogComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, true);
- fDialogComposite.setLayout(layout);
-
- Label channelNameLabel = new Label(fDialogComposite, SWT.RIGHT);
- channelNameLabel.setText(Messages.TraceControl_EnableChannelNameLabel);
- fChannelNameText = new Text(fDialogComposite, SWT.NONE);
- fChannelNameText.setToolTipText(Messages.TraceControl_EnableChannelNameTooltip);
-
- Label subBufferSizeLabel = new Label(fDialogComposite, SWT.RIGHT);
- subBufferSizeLabel.setText(Messages.TraceControl_SubBufferSizePropertyName);
- fSubBufferSizeText = new Text(fDialogComposite, SWT.NONE);
- fSubBufferSizeText.setToolTipText(Messages.TraceControl_EnableChannelSubBufferSizeTooltip);
- fSubBufferSizeText.addVerifyListener(fVerifyListener);
-
- Label numSubBufferLabel = new Label(fDialogComposite, SWT.RIGHT);
- numSubBufferLabel.setText(Messages.TraceControl_NbSubBuffersPropertyName);
- fNumberOfSubBuffersText = new Text(fDialogComposite, SWT.NONE);
- fNumberOfSubBuffersText.setToolTipText(Messages.TraceControl_EnableChannelNbSubBuffersTooltip);
- fNumberOfSubBuffersText.addVerifyListener(fVerifyListener);
-
- Label switchTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
- switchTimerLabel.setText(Messages.TraceControl_SwitchTimerPropertyName);
- fSwitchTimerText = new Text(fDialogComposite, SWT.NONE);
- fSwitchTimerText.setToolTipText(Messages.TraceControl_EnableChannelSwitchTimerTooltip);
- fSwitchTimerText.addVerifyListener(fVerifyListener);
-
- Label readTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
- readTimerLabel.setText(Messages.TraceControl_ReadTimerPropertyName);
- fReadTimerText = new Text(fDialogComposite, SWT.NONE);
- fReadTimerText.setToolTipText(Messages.TraceControl_EnableChannelReadTimerTooltip);
- fReadTimerText.addVerifyListener(fVerifyListener);
-
- Group discardModeGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- discardModeGroup.setText(Messages.TraceControl_EnableChannelDiscardModeGroupName);
- layout = new GridLayout(2, true);
- discardModeGroup.setLayout(layout);
-
- fDiscardModeButton = new Button(discardModeGroup, SWT.RADIO);
- fDiscardModeButton.setText(Messages.TraceControl_EnableChannelDiscardModeLabel);
- fDiscardModeButton.setToolTipText(Messages.TraceControl_EnableChannelDiscardModeTooltip);
- fDiscardModeButton.setSelection(true);
-
- fOverwriteModeButton = new Button(discardModeGroup, SWT.RADIO);
- fOverwriteModeButton.setText(Messages.TraceControl_EnableChannelOverwriteModeLabel);
- fOverwriteModeButton.setToolTipText(Messages.TraceControl_EnableChannelOverwriteModeTooltip);
- fOverwriteModeButton.setSelection(false);
-
- fDomainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
- fDomainGroup.setText(Messages.TraceControl_DomainDisplayName);
- layout = new GridLayout(2, true);
- fDomainGroup.setLayout(layout);
-
- fKernelButton = new Button(fDomainGroup, SWT.RADIO);
- fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
- fKernelButton.setSelection(fIsKernel);
- fUstButton = new Button(fDomainGroup, SWT.RADIO);
- fUstButton.setText(Messages.TraceControl_UstDisplayName);
- fUstButton.setSelection(!fIsKernel);
-
- if (fDomain != null) {
- fKernelButton.setEnabled(false);
- fUstButton.setEnabled(false);
- }
-
- // layout widgets
- GridData data = new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1);
- discardModeGroup.setLayoutData(data);
- data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
- fDiscardModeButton.setLayoutData(data);
- data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
- fOverwriteModeButton.setLayoutData(data);
-
- data = new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1);
- fDomainGroup.setLayoutData(data);
-
- data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
- fKernelButton.setLayoutData(data);
- data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
- fUstButton.setLayoutData(data);
-
- data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- fSubBufferSizeText.setText("666.666.666.666"); //$NON-NLS-1$
- Point minSize = fSubBufferSizeText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- data.widthHint = minSize.x + 5;
-
- fChannelNameText.setLayoutData(data);
- fSubBufferSizeText.setLayoutData(data);
- fNumberOfSubBuffersText.setLayoutData(data);
- fSwitchTimerText.setLayoutData(data);
- fReadTimerText.setLayoutData(data);
-
- fSubBufferSizeText.setText(""); //$NON-NLS-1$
-
- setDefaults();
-
- return fDialogComposite;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.DETAILS_ID, "&Default", true); //$NON-NLS-1$
- createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$
- createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- @Override
- protected void okPressed() {
- // Set channel information
- fChannelInfo = new ChannelInfo(fChannelNameText.getText());
- fChannelInfo.setSubBufferSize(Long.parseLong(fSubBufferSizeText.getText()));
- fChannelInfo.setNumberOfSubBuffers(Integer.parseInt(fNumberOfSubBuffersText.getText()));
- fChannelInfo.setSwitchTimer(Long.parseLong(fSwitchTimerText.getText()));
- fChannelInfo.setReadTimer(Long.parseLong(fReadTimerText.getText()));
- fChannelInfo.setOverwriteMode(fOverwriteModeButton.getSelection());
-
- fIsKernel = fKernelButton.getSelection();
-
- // Check for invalid names
- if (!fChannelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableChannelDialogTitle,
- Messages.TraceControl_InvalidChannelNameError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- // Check for duplicate names
- if (fDomain != null && fDomain.containsChild(fChannelInfo.getName())) {
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableChannelDialogTitle,
- Messages.TraceControl_ChannelAlreadyExistsError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- // validation successful -> call super.okPressed()
- super.okPressed();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
- */
- @Override
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.DETAILS_ID) {
- setDefaults();
- return;
- }
- super.buttonPressed(buttonId);
- }
-
- // ------------------------------------------------------------------------
- // Helper methods
- // ------------------------------------------------------------------------
- /**
- * Sets default value depending on Kernel or UST
- */
- private void setDefaults() {
- fSwitchTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_SWITCH_TIMER));
- fReadTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_READ_TIMER));
- fOverwriteModeButton.setSelection(IChannelInfo.DEFAULT_OVERWRITE_MODE);
- if (fKernelButton.getSelection()) {
- fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_KERNEL));
- fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL));
- } else {
- fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_UST));
- fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_UST));
- }
- }
-}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * <b><u>EnableChannelDialog</u></b>
+ * <p>
+ * Dialog box for collecting channel information when enabling a channel (which will be created).
+ * </p>
+ */
+public class EnableChannelDialog extends Dialog implements IEnableChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String ENABLE_CHANNEL_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ /**
+ * The text widget for the channel name
+ */
+ private Text fChannelNameText = null;
+ /**
+ * The discard mode of the channel.
+ */
+ private Button fDiscardModeButton = null;
+ /**
+ * The overwrite mode of the channel.
+ */
+ private Button fOverwriteModeButton = null;
+ /**
+ * The sub-buffer size of the channel.
+ */
+ private Text fSubBufferSizeText = null;
+ /**
+ * The number of sub-buffers of the channel.
+ */
+ private Text fNumberOfSubBuffersText = null;
+ /**
+ * The switch timer interval of the channel.
+ */
+ private Text fSwitchTimerText = null;
+ /**
+ * The read timer interval of the channel.
+ */
+ private Text fReadTimerText = null;
+ /**
+ * Group composite for domain selection.
+ */
+ private Group fDomainGroup = null;
+ /**
+ * Radio button for selecting kernel domain.
+ */
+ private Button fKernelButton = null;
+ /**
+ * Radio button for selecting UST domain.
+ */
+ private Button fUstButton = null;
+ /**
+ * The parent domain component where the channel node should be added.
+ * Null in case of creation on session level.
+ */
+ private TraceDomainComponent fDomain = null;
+ /**
+ * Common verify listener for numeric text input.
+ */
+ private VerifyListener fVerifyListener = null;
+ /**
+ * Output channel information.
+ */
+ private IChannelInfo fChannelInfo = null;
+ /**
+ * Output domain information. True in case of Kernel domain. False for UST.
+ */
+ private boolean fIsKernel;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ */
+ public EnableChannelDialog(Shell shell) {
+ super(shell);
+ fIsKernel = true;
+
+ // Common verify listener
+ fVerifyListener = new VerifyListener() {
+ @Override
+ public void verifyText(VerifyEvent e) {
+ // only numbers are allowed.
+ e.doit = e.text.matches("[0-9]*"); //$NON-NLS-1$
+ }
+ };
+ setShellStyle(SWT.RESIZE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#getChannelInfo()
+ */
+ @Override
+ public IChannelInfo getChannelInfo() {
+ return fChannelInfo;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#setDomainComponent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent)
+ */
+ @Override
+ public void setDomainComponent(TraceDomainComponent domain) {
+ fDomain = domain;
+ if (fDomain != null) {
+ fIsKernel = fDomain.isKernel();
+ } else {
+ fIsKernel = true;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#isKernel()
+ */
+ @Override
+ public boolean isKernel() {
+ return fIsKernel;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_EnableChannelDialogTitle);
+ newShell.setImage(Activator.getDefault().loadIcon(ENABLE_CHANNEL_ICON_FILE));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // Main dialog panel
+ fDialogComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(3, true);
+ fDialogComposite.setLayout(layout);
+
+ Label channelNameLabel = new Label(fDialogComposite, SWT.RIGHT);
+ channelNameLabel.setText(Messages.TraceControl_EnableChannelNameLabel);
+ fChannelNameText = new Text(fDialogComposite, SWT.NONE);
+ fChannelNameText.setToolTipText(Messages.TraceControl_EnableChannelNameTooltip);
+
+ Label subBufferSizeLabel = new Label(fDialogComposite, SWT.RIGHT);
+ subBufferSizeLabel.setText(Messages.TraceControl_SubBufferSizePropertyName);
+ fSubBufferSizeText = new Text(fDialogComposite, SWT.NONE);
+ fSubBufferSizeText.setToolTipText(Messages.TraceControl_EnableChannelSubBufferSizeTooltip);
+ fSubBufferSizeText.addVerifyListener(fVerifyListener);
+
+ Label numSubBufferLabel = new Label(fDialogComposite, SWT.RIGHT);
+ numSubBufferLabel.setText(Messages.TraceControl_NbSubBuffersPropertyName);
+ fNumberOfSubBuffersText = new Text(fDialogComposite, SWT.NONE);
+ fNumberOfSubBuffersText.setToolTipText(Messages.TraceControl_EnableChannelNbSubBuffersTooltip);
+ fNumberOfSubBuffersText.addVerifyListener(fVerifyListener);
+
+ Label switchTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
+ switchTimerLabel.setText(Messages.TraceControl_SwitchTimerPropertyName);
+ fSwitchTimerText = new Text(fDialogComposite, SWT.NONE);
+ fSwitchTimerText.setToolTipText(Messages.TraceControl_EnableChannelSwitchTimerTooltip);
+ fSwitchTimerText.addVerifyListener(fVerifyListener);
+
+ Label readTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
+ readTimerLabel.setText(Messages.TraceControl_ReadTimerPropertyName);
+ fReadTimerText = new Text(fDialogComposite, SWT.NONE);
+ fReadTimerText.setToolTipText(Messages.TraceControl_EnableChannelReadTimerTooltip);
+ fReadTimerText.addVerifyListener(fVerifyListener);
+
+ Group discardModeGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ discardModeGroup.setText(Messages.TraceControl_EnableChannelDiscardModeGroupName);
+ layout = new GridLayout(2, true);
+ discardModeGroup.setLayout(layout);
+
+ fDiscardModeButton = new Button(discardModeGroup, SWT.RADIO);
+ fDiscardModeButton.setText(Messages.TraceControl_EnableChannelDiscardModeLabel);
+ fDiscardModeButton.setToolTipText(Messages.TraceControl_EnableChannelDiscardModeTooltip);
+ fDiscardModeButton.setSelection(true);
+
+ fOverwriteModeButton = new Button(discardModeGroup, SWT.RADIO);
+ fOverwriteModeButton.setText(Messages.TraceControl_EnableChannelOverwriteModeLabel);
+ fOverwriteModeButton.setToolTipText(Messages.TraceControl_EnableChannelOverwriteModeTooltip);
+ fOverwriteModeButton.setSelection(false);
+
+ fDomainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ fDomainGroup.setText(Messages.TraceControl_DomainDisplayName);
+ layout = new GridLayout(2, true);
+ fDomainGroup.setLayout(layout);
+
+ fKernelButton = new Button(fDomainGroup, SWT.RADIO);
+ fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
+ fKernelButton.setSelection(fIsKernel);
+ fUstButton = new Button(fDomainGroup, SWT.RADIO);
+ fUstButton.setText(Messages.TraceControl_UstDisplayName);
+ fUstButton.setSelection(!fIsKernel);
+
+ if (fDomain != null) {
+ fKernelButton.setEnabled(false);
+ fUstButton.setEnabled(false);
+ }
+
+ // layout widgets
+ GridData data = new GridData(GridData.FILL, GridData.CENTER, false, false, 3, 1);
+ discardModeGroup.setLayoutData(data);
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fDiscardModeButton.setLayoutData(data);
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fOverwriteModeButton.setLayoutData(data);
+
+ data = new GridData(GridData.FILL, GridData.CENTER, false, false, 3, 1);
+ fDomainGroup.setLayoutData(data);
+
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fKernelButton.setLayoutData(data);
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fUstButton.setLayoutData(data);
+
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+
+ fChannelNameText.setLayoutData(data);
+ fSubBufferSizeText.setLayoutData(data);
+ fNumberOfSubBuffersText.setLayoutData(data);
+ fSwitchTimerText.setLayoutData(data);
+ fReadTimerText.setLayoutData(data);
+
+ setDefaults();
+
+ return fDialogComposite;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.DETAILS_ID, "&Default", true); //$NON-NLS-1$
+ createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // Set channel information
+ fChannelInfo = new ChannelInfo(fChannelNameText.getText());
+ fChannelInfo.setSubBufferSize(Long.parseLong(fSubBufferSizeText.getText()));
+ fChannelInfo.setNumberOfSubBuffers(Integer.parseInt(fNumberOfSubBuffersText.getText()));
+ fChannelInfo.setSwitchTimer(Long.parseLong(fSwitchTimerText.getText()));
+ fChannelInfo.setReadTimer(Long.parseLong(fReadTimerText.getText()));
+ fChannelInfo.setOverwriteMode(fOverwriteModeButton.getSelection());
+
+ fIsKernel = fKernelButton.getSelection();
+
+ // Check for invalid names
+ if (!fChannelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableChannelDialogTitle,
+ Messages.TraceControl_InvalidChannelNameError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // Check for duplicate names
+ if (fDomain != null && fDomain.containsChild(fChannelInfo.getName())) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableChannelDialogTitle,
+ Messages.TraceControl_ChannelAlreadyExistsError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // validation successful -> call super.okPressed()
+ super.okPressed();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.DETAILS_ID) {
+ setDefaults();
+ return;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ /**
+ * Sets default value depending on Kernel or UST
+ */
+ private void setDefaults() {
+ fSwitchTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_SWITCH_TIMER));
+ fReadTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_READ_TIMER));
+ fOverwriteModeButton.setSelection(IChannelInfo.DEFAULT_OVERWRITE_MODE);
+ if (fKernelButton.getSelection()) {
+ fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_KERNEL));
+ fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL));
+ } else {
+ fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_UST));
+ fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_UST));
+ }
+ }
+}
/**
* The icon file for this dialog box.
*/
- public static final String ENABLE_EVENT_ICON_FILE = "icons/elcl16/enable.gif"; //$NON-NLS-1$
+ public static final String ENABLE_EVENT_ICON_FILE = "icons/elcl16/enable_event.gif"; //$NON-NLS-1$
// ------------------------------------------------------------------------
// Attributes
/**
* The icon file for this dialog box.
*/
- public static final String TARGET_NEW_CONNECTION_ICON_FILE = "icons/elcl16/enable.gif"; //$NON-NLS-1$
+ public static final String TARGET_NEW_CONNECTION_ICON_FILE = "icons/elcl16/enable_event.gif"; //$NON-NLS-1$
// ------------------------------------------------------------------------
// Attributes
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
-
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
-
-/**
- * <b><u>ICreateChannelDialog</u></b>
- * <p>
- * Interface for the create channel dialog when domain is known.
- * </p>
- */
-public interface ICreateChannelDialog {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return the configuration info for the new channel.
- */
- public IChannelInfo getChannelInfo();
-
- /**
- * Sets the domain component
- * @param domain - the trace domain component
- */
- public void setDomainComponent(TraceDomainComponent domain);
-
- /**
- * @return true for Kernel domain. False for UST.
- */
- public boolean isKernel();
-
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * @return the open return value
- */
- int open();
-}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * <b><u>IEnableChannelDialog</u></b>
+ * <p>
+ * Interface for the enable channel dialog when domain is known.
+ * </p>
+ */
+public interface IEnableChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the configuration info for the new channel.
+ */
+ public IChannelInfo getChannelInfo();
+
+ /**
+ * Sets the domain component
+ * @param domain - the trace domain component
+ */
+ public void setDomainComponent(TraceDomainComponent domain);
+
+ /**
+ * @return true for Kernel domain. False for UST.
+ */
+ public boolean isKernel();
+
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return the open return value
+ */
+ int open();
+}
private INewConnectionDialog fNewConnectionDialog;
/**
- * The create channel dialog (on domain level)
+ * The enable channel dialog
*/
- private ICreateChannelDialog fCreateChannelDialog;
+ private IEnableChannelDialog fEnableChannelDialog;
/**
* The create session dialog.
}
/**
- * @return create channel dialog (on domain level)
+ * @return enable channel dialog
*/
- public ICreateChannelDialog getCreateChannelDialog() {
- if (fCreateChannelDialog == null) {
- fCreateChannelDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ public IEnableChannelDialog getEnableChannelDialog() {
+ if (fEnableChannelDialog == null) {
+ fEnableChannelDialog = new EnableChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
}
- return fCreateChannelDialog;
+ return fEnableChannelDialog;
}
/**
- * Sets a create channel dialog implementation (on domain level).
- * @param createChannelDialog - a create channel dialog implementation
+ * Sets a enable channel dialog implementation.
+ * @param createEnableDialog - a create channel dialog implementation
*/
- public void setCreateChannelDialog(ICreateChannelDialog createChannelDialog) {
- fCreateChannelDialog = createChannelDialog;
+ public void setEnableChannelDialog(IEnableChannelDialog createEnableDialog) {
+ fEnableChannelDialog = createEnableDialog;
}
/**
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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.window.Window;
-import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
-
-/**
- * <b><u>BaseCreateChannelHandler</u></b>
- * <p>
- * Base implementation of aCommand handler implementation to create a trace channel.
- * </p>
- */
-abstract class BaseCreateChannelHandler extends BaseControlViewHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- protected CommandParameter fParam;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /**
- * Enables channels with given names which are part of this domain. If a given channel
- * doesn't exists it creates a new channel with the given parameters (or default values
- * if given parameter is null).
- * @param - a parameter instance with data for the command execution
- * @param channelNames - a list of channel names to enable on this domain
- * @param info - channel information to set for the channel (use null for default)
- * @param isKernel - a flag for indicating kernel or UST.
- * @param monitor - a progress monitor
- * @throws ExecutionException
- */
- abstract public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * @param - a parameter instance with data for the command execution
- * @return returns the relevant domain (null if domain is not known)
- */
- abstract public TraceDomainComponent getDomain(CommandParameter param);
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- fLock.lock();
- try {
- final CommandParameter param = fParam.clone();
-
- final ICreateChannelDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelDialog();
- dialog.setDomainComponent(getDomain(param));
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- Job job = new Job(Messages.TraceControl_CreateChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- Exception error = null;
-
- List<String> channelNames = new ArrayList<String>();
- channelNames.add(dialog.getChannelInfo().getName());
-
- try {
- enableChannel(param, channelNames, dialog.getChannelInfo(), dialog.isKernel(), monitor);
- } catch (ExecutionException e) {
- error = e;
- }
-
- // refresh in all cases
- refresh(param);
-
- if (error != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateChannelStateFailure, error);
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
- } finally {
- fLock.unlock();
- }
- return null;
- }
-
-}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableChannelDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * <b><u>BaseEnableChannelHandler</u></b>
+ * <p>
+ * Base implementation of a command handler to enable a trace channel.
+ * </p>
+ */
+abstract class BaseEnableChannelHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ protected CommandParameter fParam;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Enables channels with given names which are part of this domain. If a given channel
+ * doesn't exists it creates a new channel with the given parameters (or default values
+ * if given parameter is null).
+ * @param - a parameter instance with data for the command execution
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param info - channel information to set for the channel (use null for default)
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * @param - a parameter instance with data for the command execution
+ * @return returns the relevant domain (null if domain is not known)
+ */
+ abstract public TraceDomainComponent getDomain(CommandParameter param);
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ fLock.lock();
+ try {
+ final CommandParameter param = fParam.clone();
+
+ final IEnableChannelDialog dialog = TraceControlDialogFactory.getInstance().getEnableChannelDialog();
+ dialog.setDomainComponent(getDomain(param));
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_CreateChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ Exception error = null;
+
+ List<String> channelNames = new ArrayList<String>();
+ channelNames.add(dialog.getChannelInfo().getName());
+
+ try {
+ enableChannel(param, channelNames, dialog.getChannelInfo(), dialog.isKernel(), monitor);
+ } catch (ExecutionException e) {
+ error = e;
+ }
+
+ // refresh in all cases
+ refresh(param);
+
+ if (error != null) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateChannelStateFailure, error);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
+ return null;
+ }
+
+}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>CreateChannelOnDomainHandler</u></b>
- * <p>
- * Command handler implementation to create a trace channel for known domain.
- * </p>
- */
-public class CreateChannelOnDomainHandler extends BaseCreateChannelHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#enableChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- if (param instanceof DomainCommandParameter) {
- ((DomainCommandParameter)param).getDomain().enableChannels(channelNames, info, monitor);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
- */
- @Override
- public TraceDomainComponent getDomain(CommandParameter param) {
- if (param instanceof DomainCommandParameter) {
- return ((DomainCommandParameter)param).getDomain();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- TraceDomainComponent domain = null;
- TraceSessionComponent session = null;
-
- // Check if one domain is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceDomainComponent) {
- TraceDomainComponent tmpDomain = (TraceDomainComponent) element;
- session = (TraceSessionComponent) tmpDomain.getParent();
-
- // Add only TraceDomainComponent whose TraceSessionComponent parent is inactive and not destroyed
- if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
- domain = tmpDomain;
- }
- }
- }
- }
-
- boolean isEnabled = domain != null;
-
- fLock.lock();
- try {
- fParam = null;
- if (isEnabled) {
- fParam = new DomainCommandParameter(session, domain);
- }
- } finally {
- fLock.unlock();
- }
-
- return isEnabled;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * <b><u>CreateChannelOnSessionHandler</u></b>
- * <p>
- * Command handler implementation to create a trace channel for unknown domain
- * (on session level).
- * </p>
- */
-public class CreateChannelOnSessionHandler extends BaseCreateChannelHandler {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#enableChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- param.getSession().enableChannels(channelNames, info, isKernel, monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
- */
- @Override
- public TraceDomainComponent getDomain(CommandParameter param) {
- return null;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- TraceSessionComponent session = null;
- // Check if one session is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- StructuredSelection structered = ((StructuredSelection) selection);
- for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
- if (element instanceof TraceSessionComponent) {
- // Add only TraceSessionComponents that are inactive and not destroyed
- TraceSessionComponent tmpSession = (TraceSessionComponent) element;
- if ((tmpSession.getSessionState() == TraceSessionState.INACTIVE) && (!tmpSession.isDestroyed())) {
- session = tmpSession;
- }
- }
- }
- }
- boolean isEnabled = session != null;
-
- fLock.lock();
- try {
- fParam = null;
- if (isEnabled) {
- fParam = new CommandParameter(session);
- }
- } finally {
- fLock.unlock();
- }
-
- return isEnabled;
- }
-}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>EnableChannelOnDomainHandler</u></b>
+ * <p>
+ * Command handler implementation to enable a trace channel for known domain.
+ * </p>
+ */
+public class EnableChannelOnDomainHandler extends BaseEnableChannelHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#enableChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof DomainCommandParameter) {
+ ((DomainCommandParameter)param).getDomain().enableChannels(channelNames, info, monitor);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
+ */
+ @Override
+ public TraceDomainComponent getDomain(CommandParameter param) {
+ if (param instanceof DomainCommandParameter) {
+ return ((DomainCommandParameter)param).getDomain();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ TraceDomainComponent domain = null;
+ TraceSessionComponent session = null;
+
+ // Check if one domain is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceDomainComponent) {
+ TraceDomainComponent tmpDomain = (TraceDomainComponent) element;
+ session = (TraceSessionComponent) tmpDomain.getParent();
+
+ // Add only TraceDomainComponent whose TraceSessionComponent parent is inactive and not destroyed
+ if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
+ domain = tmpDomain;
+ }
+ }
+ }
+ }
+
+ boolean isEnabled = domain != null;
+
+ fLock.lock();
+ try {
+ fParam = null;
+ if (isEnabled) {
+ fParam = new DomainCommandParameter(session, domain);
+ }
+ } finally {
+ fLock.unlock();
+ }
+
+ return isEnabled;
+ }
+
+}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>EnableChannelOnSessionHandler</u></b>
+ * <p>
+ * Command handler implementation to enable a trace channel for unknown domain
+ * (on session level).
+ * </p>
+ */
+public class EnableChannelOnSessionHandler extends BaseEnableChannelHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#enableChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ param.getSession().enableChannels(channelNames, info, isKernel, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
+ */
+ @Override
+ public TraceDomainComponent getDomain(CommandParameter param) {
+ return null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ TraceSessionComponent session = null;
+ // Check if one session is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof TraceSessionComponent) {
+ // Add only TraceSessionComponents that are inactive and not destroyed
+ TraceSessionComponent tmpSession = (TraceSessionComponent) element;
+ if ((tmpSession.getSessionState() == TraceSessionState.INACTIVE) && (!tmpSession.isDestroyed())) {
+ session = tmpSession;
+ }
+ }
+ }
+ }
+ boolean isEnabled = session != null;
+
+ fLock.lock();
+ try {
+ fParam = null;
+ if (isEnabled) {
+ fParam = new CommandParameter(session);
+ }
+ } finally {
+ fLock.unlock();
+ }
+
+ return isEnabled;
+ }
+}