From: Bernd Hufmann Date: Mon, 23 Apr 2012 19:21:19 +0000 (-0400) Subject: Update enable channel and event dialogs and handlers X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=d62bfa55b9869503b62adb576f50bf8743129ab0;p=deliverable%2Ftracecompass.git Update enable channel and event dialogs and handlers --- diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelSessionTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelSessionTests.java index ac70305ced..4843b4f9f9 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelSessionTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlKernelSessionTests.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; 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; @@ -173,13 +173,13 @@ public class TraceControlKernelSessionTests extends TestCase { 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(); @@ -216,7 +216,7 @@ public class TraceControlKernelSessionTests extends TestCase { info.setReadTimer(200); channelStub.setChannelInfo(info); - fFacility.executeCommand(domains[0], "createChannelOnDomain"); + fFacility.executeCommand(domains[0], "enableChannelOnDomain"); // Get Kernel domain component instance domains = session.getChildren(); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstProviderTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstProviderTests.java index 0994ffe057..3aeba2ab39 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstProviderTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstProviderTests.java @@ -20,7 +20,7 @@ import junit.framework.TestSuite; 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; @@ -183,18 +183,18 @@ public class TraceControlUstProviderTests extends TestCase { 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(); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstSessionTests.java b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstSessionTests.java index 5b6d320630..d5189bddd3 100644 --- a/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstSessionTests.java +++ b/org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlUstSessionTests.java @@ -22,7 +22,7 @@ import junit.framework.TestSuite; 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; @@ -170,11 +170,11 @@ public class TraceControlUstSessionTests extends TestCase { // ------------------------------------------------------------------------ // 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(); @@ -211,7 +211,7 @@ public class TraceControlUstSessionTests extends TestCase { info.setReadTimer(200); channelStub.setChannelInfo(info); - fFacility.executeCommand(domains[0], "createChannelOnDomain"); + fFacility.executeCommand(domains[0], "enableChannelOnDomain"); // Get Kernel domain component instance domains = session.getChildren(); diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/CreateChannelDialogStub.java b/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/CreateChannelDialogStub.java deleted file mode 100644 index 187f9cc40e..0000000000 --- a/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/CreateChannelDialogStub.java +++ /dev/null @@ -1,76 +0,0 @@ -/********************************************************************** - * 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 diff --git a/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/EnableChannelDialogStub.java b/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/EnableChannelDialogStub.java new file mode 100644 index 0000000000..532d5f4d12 --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/EnableChannelDialogStub.java @@ -0,0 +1,76 @@ +/********************************************************************** + * 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 diff --git a/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/disable_event.gif b/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/disable_event.gif new file mode 100644 index 0000000000..2966a28163 Binary files /dev/null and b/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/disable_event.gif differ diff --git a/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/enable_event.gif b/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/enable_event.gif new file mode 100644 index 0000000000..06d007905b Binary files /dev/null and b/org.eclipse.linuxtools.lttng2.ui/icons/elcl16/enable_event.gif differ diff --git a/org.eclipse.linuxtools.lttng2.ui/plugin.properties b/org.eclipse.linuxtools.lttng2.ui/plugin.properties index e99ca54713..6009a23ad8 100644 --- a/org.eclipse.linuxtools.lttng2.ui/plugin.properties +++ b/org.eclipse.linuxtools.lttng2.ui/plugin.properties @@ -90,8 +90,11 @@ commands.control.create.session.description=Create a Trace Session 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 diff --git a/org.eclipse.linuxtools.lttng2.ui/plugin.xml b/org.eclipse.linuxtools.lttng2.ui/plugin.xml index 48379557b5..e686aa0ae4 100644 --- a/org.eclipse.linuxtools.lttng2.ui/plugin.xml +++ b/org.eclipse.linuxtools.lttng2.ui/plugin.xml @@ -86,15 +86,15 @@ + description="%commands.control.enable.channelOnSession.description" + id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnSession" + name="%commands.control.enable.channelOnSession"> + description="%commands.control.enable.channelOnDomain.description" + id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnDomain" + name="%commands.control.enable.channelOnDomain"> @@ -473,7 +473,7 @@ @@ -527,7 +527,7 @@ + class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableChannelOnSessionHandler" + commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnSession"> @@ -901,8 +901,8 @@ + class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.EnableChannelOnDomainHandler" + commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableChannelOnDomain"> diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/CreateChannelDialog.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/CreateChannelDialog.java deleted file mode 100644 index b250711f51..0000000000 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/CreateChannelDialog.java +++ /dev/null @@ -1,373 +0,0 @@ -/********************************************************************** - * 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; - -/** - * CreateChannelDialog - *

- * Dialog box for collecting channel creation information. - *

- */ -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)); - } - } -} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableChannelDialog.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableChannelDialog.java new file mode 100644 index 0000000000..0d8e03069a --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableChannelDialog.java @@ -0,0 +1,369 @@ +/********************************************************************** + * 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; + +/** + * EnableChannelDialog + *

+ * Dialog box for collecting channel information when enabling a channel (which will be created). + *

+ */ +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)); + } + } +} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableEventsDialog.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableEventsDialog.java index 53cd10c3ed..f10b89ad16 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableEventsDialog.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableEventsDialog.java @@ -48,7 +48,7 @@ public class EnableEventsDialog extends Dialog implements IEnableEventsDialog { /** * 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 diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/GetEventInfoDialog.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/GetEventInfoDialog.java index e2ad1fb9a4..f43905cbe0 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/GetEventInfoDialog.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/GetEventInfoDialog.java @@ -47,7 +47,7 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog { /** * 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 diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ICreateChannelDialog.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ICreateChannelDialog.java deleted file mode 100644 index 49679e89d4..0000000000 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/ICreateChannelDialog.java +++ /dev/null @@ -1,52 +0,0 @@ -/********************************************************************** - * 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; - -/** - * ICreateChannelDialog - *

- * Interface for the create channel dialog when domain is known. - *

- */ -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(); -} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/IEnableChannelDialog.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/IEnableChannelDialog.java new file mode 100644 index 0000000000..84b74167c6 --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/IEnableChannelDialog.java @@ -0,0 +1,52 @@ +/********************************************************************** + * 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; + +/** + * IEnableChannelDialog + *

+ * Interface for the enable channel dialog when domain is known. + *

+ */ +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(); +} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/TraceControlDialogFactory.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/TraceControlDialogFactory.java index 695a0f7ca8..8ef9e7c261 100644 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/TraceControlDialogFactory.java +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/TraceControlDialogFactory.java @@ -20,9 +20,9 @@ final public class TraceControlDialogFactory { private INewConnectionDialog fNewConnectionDialog; /** - * The create channel dialog (on domain level) + * The enable channel dialog */ - private ICreateChannelDialog fCreateChannelDialog; + private IEnableChannelDialog fEnableChannelDialog; /** * The create session dialog. @@ -102,21 +102,21 @@ final public class TraceControlDialogFactory { } /** - * @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; } /** diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/BaseCreateChannelHandler.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/BaseCreateChannelHandler.java deleted file mode 100644 index 1bb2298bbe..0000000000 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/BaseCreateChannelHandler.java +++ /dev/null @@ -1,114 +0,0 @@ -/********************************************************************** - * 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; - -/** - * BaseCreateChannelHandler - *

- * Base implementation of aCommand handler implementation to create a trace channel. - *

- */ -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 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 channelNames = new ArrayList(); - 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; - } - -} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/BaseEnableChannelHandler.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/BaseEnableChannelHandler.java new file mode 100644 index 0000000000..9bcd4407ba --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/BaseEnableChannelHandler.java @@ -0,0 +1,114 @@ +/********************************************************************** + * 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; + +/** + * BaseEnableChannelHandler + *

+ * Base implementation of a command handler to enable a trace channel. + *

+ */ +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 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 channelNames = new ArrayList(); + 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; + } + +} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateChannelOnDomainHandler.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateChannelOnDomainHandler.java deleted file mode 100644 index 56b51c10bf..0000000000 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateChannelOnDomainHandler.java +++ /dev/null @@ -1,115 +0,0 @@ -/********************************************************************** - * 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; - -/** - * CreateChannelOnDomainHandler - *

- * Command handler implementation to create a trace channel for known domain. - *

- */ -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 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; - } - -} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateChannelOnSessionHandler.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateChannelOnSessionHandler.java deleted file mode 100644 index 425d814f9b..0000000000 --- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/CreateChannelOnSessionHandler.java +++ /dev/null @@ -1,104 +0,0 @@ -/********************************************************************** - * 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; - -/** - * CreateChannelOnSessionHandler - *

- * Command handler implementation to create a trace channel for unknown domain - * (on session level). - *

- */ -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 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; - } -} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableChannelOnDomainHandler.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableChannelOnDomainHandler.java new file mode 100644 index 0000000000..3b925a0f74 --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableChannelOnDomainHandler.java @@ -0,0 +1,115 @@ +/********************************************************************** + * 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; + +/** + * EnableChannelOnDomainHandler + *

+ * Command handler implementation to enable a trace channel for known domain. + *

+ */ +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 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; + } + +} diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableChannelOnSessionHandler.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableChannelOnSessionHandler.java new file mode 100644 index 0000000000..8602661299 --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableChannelOnSessionHandler.java @@ -0,0 +1,104 @@ +/********************************************************************** + * 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; + +/** + * EnableChannelOnSessionHandler + *

+ * Command handler implementation to enable a trace channel for unknown domain + * (on session level). + *

+ */ +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 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; + } +}