control: Base code for profile dialog window
authorPatrick-Jeffrey Pollo Guilbert <patrick.pollo.guilbert@gmail.com>
Fri, 3 Apr 2015 03:02:32 +0000 (23:02 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 28 Oct 2015 04:03:32 +0000 (00:03 -0400)
Modified ILttngControlService to add a loadSession command, also
implemented the methods in the appropriate children classes
(LTTngControlService and NullControlService).

Added ProfileDialog and ProfileHandler, as well as the appropriate
modifications to the plugin.xml to allow the execution of the handler as
well as the call to the Handler. As for now, pre-selected profiles must
be in
org.eclipse.tracecompass.internal.lttng2.control.ui/resources/folders.txt.
Appropriate .icons, strings and whatnot are externalized and at the
appropriate location > messages.properties.

Signed-off-by: Patrick-Jeffrey Pollo Guilbert <patrick.pollo.guilbert@gmail.com>
Signed-off-by: William Tri-Khiem Truong <tri-khiem-william.truong@polymtl.ca>
Signed-off-by: William Enright <william.enright@polymtl.ca>
Change-Id: Id312708b1907f3dd36fab65da7d96d5f917404a2
Reviewed-on: https://git.eclipse.org/r/45958
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
20 files changed:
lttng/org.eclipse.tracecompass.lttng2.control.ui/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.control.ui/plugin.properties
lttng/org.eclipse.tracecompass.lttng2.control.ui/plugin.xml
lttng/org.eclipse.tracecompass.lttng2.control.ui/resources/cpu.lttng [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui/resources/cpu2.lttng [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ConnectionContentProvider.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ConnectionTreeLabelProvider.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/EnableKernelEventComposite.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ProfileDialog.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/ConnectionPage.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/NewConnectionHandler.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/NewConnectionWizard.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/ProfileHandler.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/messages/Messages.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/messages/messages.properties
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/model/impl/NullControlService.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/ILttngControlService.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java

index 8e0ae4575fd220ee5dee5a38104237d5209f95f5..4325559b83d75454ec59d29707d18969a172332e 100644 (file)
@@ -22,7 +22,10 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.remote.ui;bundle-version="2.0.0",
  org.eclipse.tracecompass.tmf.remote.core,
  org.eclipse.tracecompass.tmf.remote.ui,
- org.eclipse.core.filesystem
+ org.eclipse.core.filesystem,
+ org.eclipse.jface,
+ org.eclipse.core.commands,
+ org.eclipse.ui.workbench
 Export-Package: org.eclipse.tracecompass.internal.lttng2.control.ui;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests",
  org.eclipse.tracecompass.internal.lttng2.control.ui.relayd;x-internal:=true,
  org.eclipse.tracecompass.internal.lttng2.control.ui.views;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui,org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests",
index 44c24c66cddfcef63f195ec315a35060ccbf918e..872e182ada6313ebf1ad807f19daea1f70439d02 100644 (file)
@@ -130,12 +130,18 @@ commands.control.add.context.description=Add Context to Channel(s) and/or Event(
 commands.control.import=Import...
 commands.control.import.description=Import Traces to LTTng Project
 
+commands.control.record=Record...
+commands.control.record.description=Record a tracing session with basic options
+
 commands.control.calibrate=Calibrate
 commands.control.calibrate.description=Quantify LTTng overhead
 
 commands.control.snapshot=Record Snapshot
 commands.control.snapshot.description=Record a snapshot
 
+commands.control.wizard=Record...
+commands.control.wizard.description=Create automated tracing session
+
 preference.page.control.name=LTTng Tracer Control Preferences
 
 commandParameter.remoteServicesId.name = Remote Services ID
index 2da1f5e96e2fcf61997e59a8cb79c8de5b05621e..f2878a4ff2b1ad5d6f2b02da5a0ca50e8a323bd5 100644 (file)
             id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.snapshot"
             name="%commands.control.snapshot">
       </command>
+      <command
+            defaultHandler="org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.ProfileHandler"
+            description="%commands.control.wizard.description"
+            id="org.eclipse.tracecompass.lttng2.control.ui.wizard"
+            name="%commands.control.wizard">
+      </command>
 
    </extension>
    <extension
                label="%commands.control.import"
                style="push">
          </command>
+         <command
+               commandId="org.eclipse.tracecompass.lttng2.control.ui.wizard"
+               icon="icons/elcl16/add_button.gif"
+               label="%commands.control.record"
+               style="push">
+         </command>
          
       </menuContribution>
       <menuContribution
                style="push">
             <visibleWhen
                   checkEnabled="false">
-               <with
-                     variable="activeMenuSelection">
-                  <iterate
-                        operator="or">
-                     <instanceof
-                           value="org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup">
-                     </instanceof>
-                  </iterate>
-               </with>
             </visibleWhen>
          </command>
          <command
                </with>
             </visibleWhen>
          </command>
+         <command
+               commandId="org.eclipse.tracecompass.lttng2.control.ui.wizard"
+               icon="icons/obj16/channel_disabled.gif"
+               label="Record..."
+               style="push"
+               >
+            <visibleWhen
+                  checkEnabled="true">
+            </visibleWhen>
+         </command>
 
       </menuContribution>
       
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/resources/cpu.lttng b/lttng/org.eclipse.tracecompass.lttng2.control.ui/resources/cpu.lttng
new file mode 100644 (file)
index 0000000..0df601e
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Patrick-Jeffrey Pollo Guilbert - Initial API and implementation
+ **********************************************************************/
+-->
+<sessions>
+       <session>
+               <name>baseCPUtrace</name>
+               <domains>
+                       <domain>
+                               <type>KERNEL</type>
+                               <buffer_type>GLOBAL</buffer_type>
+                               <channels>
+                                       <channel>
+                                               <name>channel0</name>
+                                               <enabled>false</enabled>
+                                               <overwrite_mode>DISCARD</overwrite_mode>
+                                               <subbuffer_size>8388608</subbuffer_size>
+                                               <subbuffer_count>4</subbuffer_count>
+                                               <switch_timer_interval>0</switch_timer_interval>
+                                               <read_timer_interval>200000</read_timer_interval>
+                                               <output_type>SPLICE</output_type>
+                                               <tracefile_size>0</tracefile_size>
+                                               <tracefile_count>0</tracefile_count>
+                                               <live_timer_interval>0</live_timer_interval>
+                                               <events>
+                                                       <event>
+                                                               <name>kmem_cache_free</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_kfree</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_cache_alloc_node</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_kmalloc_node</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_cache_alloc</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_kmalloc</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>                                                
+                                               </events>
+                                       </channel>
+                               </channels>
+                       </domain>
+               </domains>
+               <started>false</started>
+       </session>
+</sessions>
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/resources/cpu2.lttng b/lttng/org.eclipse.tracecompass.lttng2.control.ui/resources/cpu2.lttng
new file mode 100644 (file)
index 0000000..abc746e
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Patrick-Jeffrey Pollo Guilbert - Initial API and implementation
+ **********************************************************************/
+-->
+<sessions>
+       <session>
+               <name>baseCPUtrace</name>
+               <domains>
+                       <domain>
+                               <type>KERNEL</type>
+                               <buffer_type>GLOBAL</buffer_type>
+                               <channels>
+                                       <channel>
+                                               <name>channel0</name>
+                                               <enabled>false</enabled>
+                                               <overwrite_mode>DISCARD</overwrite_mode>
+                                               <subbuffer_size>8388608</subbuffer_size>
+                                               <subbuffer_count>4</subbuffer_count>
+                                               <switch_timer_interval>0</switch_timer_interval>
+                                               <read_timer_interval>200000</read_timer_interval>
+                                               <output_type>SPLICE</output_type>
+                                               <tracefile_size>0</tracefile_size>
+                                               <tracefile_count>0</tracefile_count>
+                                               <live_timer_interval>0</live_timer_interval>
+                                               <events>
+                                                       <event>
+                                                               <name>kmem_cache_free</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_kfree</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_cache_alloc_node</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_kmalloc_node</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_cache_alloc</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>
+                                                       <event>
+                                                               <name>kmem_kmalloc</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                       </event>                                                
+                                               </events>
+                                       </channel>
+                               </channels>
+                       </domain>
+               </domains>
+               <started>false</started>
+       </session>
+</sessions>
\ No newline at end of file
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ConnectionContentProvider.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ConnectionContentProvider.java
new file mode 100644 (file)
index 0000000..658e345
--- /dev/null
@@ -0,0 +1,78 @@
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Patrick-Jeffrey Pollo Guilbert, William Enright,
+ *      William Tri-Khiem Truong - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+
+/**
+ * TODO document
+ *
+ */
+public final class ConnectionContentProvider implements ITreeContentProvider {
+    private static final Object[] NO_CHILDREN = {};
+
+    @Override
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+    }
+
+    @Override
+    public void dispose() {
+    }
+
+    @Override
+    public Object[] getElements(Object inputElement) {
+        List<Object> children = new ArrayList<>();
+        if (inputElement instanceof IRemoteConnectionType) {
+            IRemoteConnectionType irc = (IRemoteConnectionType) inputElement;
+            children.addAll(irc.getRemoteServicesManager().getAllRemoteConnections());
+        }
+        return children.toArray();
+    }
+
+    @Override
+    public Object[] getChildren(Object parentElement) {
+        if (parentElement instanceof IRemoteConnectionType) {
+            return getConnections((IRemoteConnectionType) parentElement);
+        }
+        return NO_CHILDREN;
+    }
+
+    static IRemoteConnection[] getConnections(IRemoteConnectionType parentElement) {
+        List<IRemoteConnection> connectionList = parentElement.getConnections();
+        IRemoteConnection[] result = connectionList.toArray(new IRemoteConnection[connectionList.size()]);
+        Arrays.sort(result);
+        return result;
+    }
+
+    @Override
+    public Object getParent(Object element) {
+        if (element instanceof IRemoteConnection) {
+            return ((IRemoteConnection) element).getConnectionType();
+        }
+        return null;
+    }
+
+    @Override
+    public boolean hasChildren(Object element) {
+        return getChildren(element).length > 0;
+    }
+
+}
\ No newline at end of file
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ConnectionTreeLabelProvider.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ConnectionTreeLabelProvider.java
new file mode 100644 (file)
index 0000000..7b43ef9
--- /dev/null
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Patrick-Jeffrey Pollo Guilbert, William Enright,
+ *      William Tri-Khiem Truong - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
+
+/**
+ * TODO
+ *
+ */
+public final class ConnectionTreeLabelProvider extends LabelProvider {
+    @Override
+    public String getText(Object element) {
+        if (element instanceof IRemoteConnection) {
+            IRemoteConnection rc = (IRemoteConnection) element;
+            return rc.getName();
+        } else if (element instanceof IRemoteConnectionType) {
+            IRemoteConnectionType rs = (IRemoteConnectionType) element;
+            return rs.getName();
+        }
+        return Messages.TraceControl_UnknownNode;
+    }
+
+    @Override
+    public Image getImage(Object element) {
+//        if (element instanceof IRemoteConnection) {
+//            return Activator.getDefault().loadIcon(NewConnectionDialog.CONNECTION_ICON_FILE);
+//        }
+//        return Activator.getDefault().loadIcon(NewConnectionDialog.PROVIDERS_ICON_FILE);
+        return null;
+    }
+}
\ No newline at end of file
index 483bbeec06aef7486b6af7d557bf8e160276f7bb..2c175f8adbf5daeafb79a2a69e6f7bfef0e674dc 100644 (file)
@@ -366,6 +366,12 @@ public class EnableKernelEventComposite extends Composite implements IEnableKern
                 fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
                 return fTracepointsViewer;
             }
+
+            @Override
+            protected void updateToolbar(boolean visible) {
+                super.updateToolbar(visible);
+                treeViewer.expandAll();
+            }
         };
     }
 
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ProfileDialog.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ProfileDialog.java
new file mode 100644 (file)
index 0000000..371affc
--- /dev/null
@@ -0,0 +1,537 @@
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Patrick-Jeffrey Pollo Guilbert, William Enright,
+ *      William Tri-Khiem Truong - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.HelpEvent;
+import org.eclipse.swt.events.HelpListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * <p>
+ * Dialog box using profiles
+ * </p>
+ *
+ * @author William Enright, Patrick-Jeffrey Pollo Guilbert, William Tri-Khiem
+ *         Truong
+ *
+ *
+ */
+public class ProfileDialog extends TitleAreaDialog {
+
+    private Composite fBase;
+    private Composite fLabel;
+    private CheckboxTreeViewer fCbtv;
+    private Text descriptionText;
+    private ArrayList<File> fSessionFiles = new ArrayList<>();
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+    /**
+     * Constructor
+     *
+     * @param parentShell
+     *            - a shell for the display of the dialog
+     */
+    public ProfileDialog(Shell parentShell) {
+        super(parentShell);
+
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+
+        setTitle(Messages.TraceControl_BasicMode);
+        setMessage(Messages.TraceControl_SelectBasicProfile);
+
+        Composite parentComp = (Composite) super.createDialogArea(parent);
+
+        fBase = new Composite(parentComp, SWT.NONE);
+
+        // Creating composite for label group
+        fLabel = new Composite(parentComp, SWT.NONE);
+        fLabel.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).create());
+        fLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+        descriptionText = new Text(fLabel, SWT.READ_ONLY | SWT.BORDER | SWT.MULTI);
+        descriptionText.setText(Messages.TraceControl_NoProfileSelected + "\n\n\n\n\n"); //$NON-NLS-1$
+        descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        descriptionText.setBackground(new Color(null, 255, 255, 255));
+        fBase.addHelpListener(new HelpListener() {
+
+            @Override
+            public void helpRequested(HelpEvent e) {
+                try {
+                    PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL("http://archive.eclipse.org/tracecompass/doc/org.eclipse.tracecompass.doc.user/LTTng-Tracer-Control.html#Control_View")); //$NON-NLS-1$
+                } catch (PartInitException e1) {
+
+                } catch (MalformedURLException e1) {
+
+                }
+
+            }
+        });
+
+        fBase.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).create());
+        fBase.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        FilteredTree ft = new FilteredTree(fBase, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true) {
+            @Override
+            protected TreeViewer doCreateTreeViewer(Composite aparent, int style) {
+                fCbtv = new CheckboxTreeViewer(fBase);
+                fCbtv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+                fCbtv.setContentProvider(new BasicContentProvider());
+                try {
+                    fCbtv.setInput(initialize());
+                } catch (IOException e) {
+
+                }
+                fCbtv.expandAll();
+                return fCbtv;
+            }
+        };
+
+        ft.setBounds(0, 0, 500, 500);
+        fCbtv.addSelectionChangedListener(new ProfileSelectionChangedListener());
+
+        return fBase;
+    }
+
+    // Updates text to be displayed in the textbox for profile description
+    private void updateSelectionText(IStructuredSelection sel, boolean uncheck)
+    {
+        Object[] obj = fCbtv.getCheckedElements();
+        obj.getClass();
+
+        if (fCbtv.getCheckedElements().length == 0)
+        {
+            descriptionText.setText(Messages.NoSelectionDescription);
+        }
+        else if (fCbtv.getCheckedElements().length != 1 && fCbtv.getCheckedElements().length != 0)
+        {
+            descriptionText.setText(Messages.TraceControl_MultipleSelectionDescription);
+        } else {
+
+            TreeParent checkedElement;
+            boolean commentFound = false;
+            if (uncheck) {
+                checkedElement = (TreeParent) obj[0];
+            } else {
+                checkedElement = (TreeParent) sel.getFirstElement();
+            }
+
+            TreeParent currentParent = checkedElement.getParent();
+            String parentPath = currentParent.getName();
+
+            if (fCbtv.getChecked(checkedElement))
+            {
+                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+                try {
+                    DocumentBuilder builder = factory.newDocumentBuilder();
+                    factory.setIgnoringComments(false);
+                    String fullPath = parentPath + checkedElement.getName();
+                    Document document = builder.parse(new File(fullPath));
+                    document.getDocumentElement().normalize();
+                    NodeList nl = document.getChildNodes();
+                    for (int i = 0; i < nl.getLength(); i++) {
+                        if (nl.item(i).getNodeType() == Node.COMMENT_NODE) {
+                            commentFound = true;
+                            Comment comment = (Comment) nl.item(i);
+                            descriptionText.setText(comment.getData());
+                        }
+                    }
+
+                    if (!commentFound) {
+                        descriptionText.setText(Messages.TraceControl_SingleSelectionDescription);
+                    }
+                } catch (ParserConfigurationException e) {
+
+                } catch (SAXException e) {
+
+                } catch (IOException e) {
+
+                }
+
+            }
+
+        }
+    }
+
+    private List<TreeParent> addCustomFolders() throws IOException
+    {
+        String basicPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
+        basicPath = basicPath + "resources/folders.txt"; //$NON-NLS-1$
+        String thisLine = ""; //$NON-NLS-1$
+        List<TreeParent> folderList = new ArrayList<>();
+
+        try (BufferedReader reader = new BufferedReader(new FileReader(basicPath))) {
+            while ((thisLine = reader.readLine()) != null) {
+
+                for (String retval : thisLine.split("\n")) { //$NON-NLS-1$
+                    if (!retval.equals("")) { //$NON-NLS-1$
+                        List<TreeParent> filesList = new ArrayList<>();
+                        TreeParent newParent = new TreeParent(thisLine);
+                        filesList = addFilesFromFolder(thisLine);
+
+                        for (int i = 0; i < filesList.size(); i++)
+                        {
+                            newParent.addChild(new TreeParent(filesList.get(i).getName()));
+                        }
+                        folderList.add(newParent);
+                    }
+                }
+            }
+        } catch (FileNotFoundException e) {
+            System.out.printf(Messages.TraceControl_ReadingPathError, basicPath);
+        }
+        return folderList;
+    }
+
+    private List<TreeParent> addFilesFromFolder(String folderPath)
+    {
+        List<TreeParent> fileList = new ArrayList<>();
+        File dir = new File(folderPath);
+        File[] files = dir.listFiles(new FilenameFilter() {
+            @Override
+            public boolean accept(File dir1, String name) {
+                return name.toLowerCase().endsWith(Messages.TraceControl_LttngSuffix);
+            }
+        });
+        if (files == null) {
+            files = new File[0];
+        }
+        for (File f : files)
+        {
+            fSessionFiles.add(f);
+            fileList.add(new TreeParent(f.getName()));
+        }
+
+        return fileList;
+
+    }
+
+    private TreeParent initialize() throws IOException {
+
+        String absolutePath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
+        String defaultPath = absolutePath + "resources/"; //$NON-NLS-1$
+
+        TreeParent root = new TreeParent("Root"); //$NON-NLS-1$
+
+        List<TreeParent> sessionFilesList = new ArrayList<>();
+        sessionFilesList = addFilesFromFolder(defaultPath);
+
+        TreeParent defaultTP = new TreeParent(defaultPath);
+
+        for (int i = 0; i < sessionFilesList.size(); i++)
+        {
+            defaultTP.addChild(sessionFilesList.get(i));
+        }
+
+        root.addChild(defaultTP);
+
+        List<TreeParent> customList = new ArrayList<>();
+        customList = addCustomFolders();
+
+        for (TreeParent tp : customList)
+        {
+            root.addChild(tp);
+        }
+
+        return root;
+    }
+
+    private final class ProfileSelectionChangedListener implements ISelectionChangedListener {
+        @Override
+        public void selectionChanged(SelectionChangedEvent event) {
+
+            if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection)
+            {
+                IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+
+                updateSelectionText(sel, false);
+                Object selectedObject = sel.getFirstElement();
+                updateCheckedProfiles(sel, selectedObject);
+            }
+        }
+
+        private void updateCheckedProfiles(IStructuredSelection sel, Object selectedObject) {
+            // Check if all the other brothers are checked, if so, check parent
+            // TreeObject is checked
+            if (fCbtv.getChecked(selectedObject)) {
+                ArrayList<TreeObject> allParents = ((TreeObject) selectedObject).getAllParents();
+                for (TreeObject parentAbove : allParents) {
+                    Boolean brothersChecked = true;
+                    ArrayList<TreeObject> allChildren = ((TreeParent) parentAbove).getAllChildren();
+                    for (TreeObject child : allChildren) {
+                        // TreeParent is checked
+                        if (!fCbtv.getChecked(child)) {
+                            brothersChecked = false;
+                        }
+                    }
+                    if (brothersChecked) {
+                        fCbtv.setChecked(parentAbove, true);
+                    }
+                }
+            }
+
+            if (selectedObject.getClass() == TreeParent.class)
+            {
+                // TreeParent is checked, must check all children
+                if (fCbtv.getChecked(selectedObject)) {
+                    ArrayList<TreeObject> allChildren = ((TreeParent) selectedObject).getAllChildren();
+                    for (TreeObject child : allChildren) {
+                        fCbtv.setChecked(child, true);
+                    }
+                    fCbtv.expandToLevel(selectedObject, AbstractTreeViewer.ALL_LEVELS);
+                }
+                // TreeParent is unchecked, must uncheck children and parent,
+                // but not brothers
+                else {
+                    ArrayList<TreeObject> allChildren = ((TreeParent) selectedObject).getAllChildren();
+                    for (TreeObject child : allChildren) {
+                        fCbtv.setChecked(child, false);
+                        updateSelectionText(sel, true);
+                    }
+                    ArrayList<TreeObject> allParents = ((TreeObject) selectedObject).getAllParents();
+                    for (TreeObject parentAbove : allParents) {
+                        fCbtv.setChecked(parentAbove, false);
+                        updateSelectionText(sel, true);
+                    }
+
+                }
+            } else if (selectedObject.getClass() == TreeObject.class) {
+                // TreeObject is checked
+                if (fCbtv.getChecked(selectedObject)) {
+
+                }
+                // TreeObject is unchecked
+                else {
+                    ArrayList<TreeObject> allParents = ((TreeObject) selectedObject).getAllParents();
+                    for (TreeObject parentAbove : allParents) {
+                        fCbtv.setChecked(parentAbove, false);
+                    }
+                }
+            }
+        }
+    }
+
+    class TreeObject extends PlatformObject {
+        private String name;
+        private TreeParent parent;
+
+        public TreeObject(String name) {
+            this.name = name;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setParent(TreeParent parent) {
+            this.parent = parent;
+        }
+
+        public TreeParent getParent() {
+            return parent;
+        }
+
+        public ArrayList<TreeObject> getAllParents() {
+            ArrayList<TreeObject> both = new ArrayList<>();
+            TreeObject parentTemp = getParent();
+            if (parentTemp != null) { // is not root, has more parents
+                both.add(parentTemp);
+                both.addAll(parentTemp.getAllParents());
+            }
+
+            return both;
+        }
+
+        @Override
+        public String toString() {
+            return getName();
+        }
+
+    }
+
+    class TreeParent extends TreeObject {
+        private ArrayList<TreeObject> children;
+
+        public TreeParent(String name) {
+            super(name);
+            children = new ArrayList<>();
+        }
+
+        public void addChild(TreeObject child) {
+            children.add(child);
+            child.setParent(this);
+        }
+
+        public void removeChild(TreeObject child) {
+            children.remove(child);
+            child.setParent(null);
+        }
+
+        public TreeObject[] getChildren() {
+            return children.toArray(new TreeObject[children.size()]);
+        }
+
+        public ArrayList<TreeObject> getAllChildren()
+        {
+            ArrayList<TreeObject> both = new ArrayList<>();
+            for (Object child : getChildren()) {
+                if (child.getClass() == TreeParent.class) { // is a parent
+                    both.add((TreeObject) child);
+                    both.addAll(((TreeParent) child).getAllChildren());
+                } else {
+                    both.add((TreeObject) child);
+                }
+            }
+            return both;
+        }
+
+        public boolean hasChildren() {
+            return children.size() > 0;
+        }
+    }
+
+    class BasicContentProvider implements ITreeContentProvider {
+        private TreeParent invisibleRoot;
+
+        @Override
+        public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+        }
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public Object[] getElements(Object parent) {
+            if (parent.equals(null)) {
+                if (invisibleRoot == null) {
+                    try {
+                        invisibleRoot = initialize();
+                    } catch (IOException e) {
+
+                    }
+                }
+                return getChildren(invisibleRoot);
+            }
+            return getChildren(parent);
+        }
+
+        @Override
+        public Object getParent(Object child) {
+            if (child instanceof TreeObject) {
+                return ((TreeObject) child).getParent();
+            }
+            return null;
+        }
+
+        @Override
+        public Object[] getChildren(Object parent) {
+            if (parent instanceof TreeParent) {
+                return ((TreeParent) parent).getChildren();
+            }
+            return new Object[0];
+        }
+
+        @Override
+        public boolean hasChildren(Object parent) {
+            if (parent instanceof TreeParent) {
+                return ((TreeParent) parent).hasChildren();
+            }
+            return false;
+        }
+    }
+
+    @Override
+    protected boolean isResizable() {
+        return true;
+    }
+
+    @Override
+    protected void okPressed()
+    {
+        Object[] checkedElements = fCbtv.getCheckedElements();
+
+        if (checkedElements.length != 0) {
+            ArrayList<File> temp = new ArrayList<>();
+            for (Object checked : checkedElements) {
+                String sessionName = ((TreeParent) checked).toString();
+                if (sessionName.endsWith(Messages.ProfileDialog_LTTNG_Suffix)) {
+
+                    for (File f : fSessionFiles) {
+                        if (f.getAbsolutePath().endsWith(sessionName)) {
+                            temp.add(f);
+                        }
+                    }
+                }
+            }
+            fSessionFiles = temp;
+        }
+
+        super.okPressed();
+    }
+
+    /**
+     * @return the list of checked files
+     */
+    public ArrayList<File> getCheckedFiles() {
+        return fSessionFiles;
+    }
+
+}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/ConnectionPage.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/ConnectionPage.java
new file mode 100644 (file)
index 0000000..7338da7
--- /dev/null
@@ -0,0 +1,207 @@
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal and others
+ *
+ * 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:
+ *   Patrick-Jeffrey Pollo Guilbert - Extracted from NewConnectionDialog
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+import org.eclipse.remote.ui.IRemoteUIConnectionService;
+import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Label;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.ConnectionContentProvider;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.ConnectionTreeLabelProvider;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
+
+final class ConnectionPage extends WizardPage {
+    /**
+         *
+         *
+         *
+         */
+
+    private static final int BUTTONS_NUMBER_OF_COLUMNS = 3;
+    private Button fNewButton;
+    private Button fEditButton;
+    private IRemoteConnection fConnection;
+    private TreeViewer fConnectionTree = null;
+
+    ConnectionPage(String pageName) {
+        super(pageName);
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        GridData gd;
+        Composite dialogComposite = new Composite(parent, SWT.NONE);
+        GridLayout layout = new GridLayout(1, true);
+        dialogComposite.setLayout(layout);
+        dialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+        Label label = new Label(dialogComposite, SWT.NONE);
+        label.setText(Messages.TraceControl_NewNodeExistingConnectionGroupName);
+        gd = new GridData();
+        label.setLayoutData(gd);
+        gd.widthHint = label.computeSize(-1, -1).x + convertWidthInCharsToPixels(NewConnectionWizard.LABEL_WIDTH_CHARS);
+        // Existing connections group
+        this.fConnectionTree = new TreeViewer(dialogComposite);
+        gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        this.fConnectionTree.getTree().setLayoutData(gd);
+        gd.widthHint = convertWidthInCharsToPixels(NewConnectionWizard.CONNECTIONTREE_WIDTH_CHARS);
+        gd.heightHint = convertHeightInCharsToPixels(NewConnectionWizard.CONNECTIONTREE_HEIGHT_CHARS);
+        fConnectionTree.setLabelProvider(new ConnectionTreeLabelProvider());
+        fConnectionTree.setContentProvider(new ConnectionContentProvider());
+        fConnectionTree.addSelectionChangedListener(new ISelectionChangedListener() {
+            @Override
+            public void selectionChanged(SelectionChangedEvent event) {
+                ConnectionPage.this.onSelectionChanged();
+            }
+        });
+        fConnectionTree.addDoubleClickListener(new IDoubleClickListener() {
+            @Override
+            public void doubleClick(DoubleClickEvent event) {
+                getWizard().performFinish();
+            }
+        });
+
+        Composite buttons = new Composite(dialogComposite, SWT.NONE);
+        layout = new GridLayout(BUTTONS_NUMBER_OF_COLUMNS, true);
+        layout.marginHeight = 0;
+        layout.marginWidth = 0;
+        buttons.setLayout(layout);
+        buttons.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
+
+        new Label(buttons, SWT.NONE);
+
+        fEditButton = new Button(buttons, SWT.PUSH);
+        fEditButton.setText(Messages.TraceControl_NewNodeEditButtonName);
+        setButtonLayoutData(fEditButton);
+        fEditButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                onEditConnection();
+            }
+        });
+
+        fNewButton = new Button(buttons, SWT.PUSH);
+        fNewButton.setText(Messages.TraceControl_NewNodeCreateButtonText);
+        setButtonLayoutData(fNewButton);
+        fNewButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                onNewConnection();
+            }
+        });
+        setControl(dialogComposite);
+
+    }
+
+    private void onSelectionChanged() {
+        setConnection();
+        setPageComplete(true);
+        fEditButton.setEnabled(canEdit(fConnection));
+        fNewButton.setEnabled(getServiceForCreation() != null);
+    }
+
+    private void onEditConnection() {
+        setConnection();
+        if (fConnection != null) {
+            IRemoteConnectionType connectionType = fConnection.getConnectionType();
+            if (connectionType != null) {
+                IRemoteUIConnectionService connManager = connectionType.getService(IRemoteUIConnectionService.class);
+                if (connManager != null) {
+                    IRemoteUIConnectionWizard wiz = connManager.getConnectionWizard(getShell());
+                    wiz.setConnection(fConnection.getWorkingCopy());
+                    IRemoteConnectionWorkingCopy result = wiz.open();
+                    if (result != null) {
+                        try {
+                            result.save();
+                        } catch (RemoteConnectionException e) {
+                            Activator.getDefault().logError(e.toString(), e);
+                        }
+                        fConnectionTree.refresh();
+                    }
+                }
+            }
+        }
+    }
+
+    private void setConnection() {
+        Object o = ((IStructuredSelection) fConnectionTree.getSelection()).getFirstElement();
+        fConnection = o instanceof IRemoteConnection ? (IRemoteConnection) o : null;
+    }
+
+    private static boolean canEdit(IRemoteConnection conn) {
+        if (conn == null) {
+            return false;
+        }
+        return conn.getConnectionType().canEdit();
+    }
+
+    private IRemoteConnectionType getServiceForCreation() {
+        Object o = ((IStructuredSelection) fConnectionTree.getSelection()).getFirstElement();
+        IRemoteConnectionType result = null;
+        if (o instanceof IRemoteConnectionType) {
+            result = (IRemoteConnectionType) o;
+        } else if (o instanceof IRemoteConnection) {
+            IRemoteConnection iRemoteConnection = (IRemoteConnection) o;
+            result = iRemoteConnection.getConnectionType();
+        } else {
+            return null;
+        }
+        if (!result.canAdd()) {
+            return null;
+        }
+
+        return result;
+    }
+
+    public void onNewConnection() {
+        IRemoteConnectionType rs = getServiceForCreation();
+        if (rs != null) {
+            IRemoteUIConnectionService uiService = rs.getService(IRemoteUIConnectionService.class);
+            if (uiService != null) {
+                IRemoteUIConnectionWizard wiz = uiService.getConnectionWizard(getShell());
+                if (wiz != null) {
+                    IRemoteConnectionWorkingCopy wc = wiz.open();
+                    if (wc != null) {
+                        IRemoteConnection conn = null;
+                        try {
+                            conn = wc.save();
+                            fConnectionTree.refresh();
+                            fConnectionTree.setSelection(new StructuredSelection(conn), true);
+                        } catch (RemoteConnectionException e) {
+                            Activator.getDefault().logError(e.toString(), e);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
index 368e86fc99b2ff875223c15b9f6c8be2ec404779..3786c172bdafbab1cf3a3f77061a87841fbe65e5 100644 (file)
@@ -17,6 +17,7 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.util.Map;
 
+import org.eclipse.core.commands.Command;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.window.Window;
@@ -32,6 +33,8 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.services.IServiceLocator;
 
 /**
  * <p>
@@ -98,6 +101,28 @@ public class NewConnectionHandler extends BaseControlViewHandler {
                 fLock.unlock();
             }
         }
+
+        // Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench():
+        IServiceLocator serviceLocator = PlatformUI.getWorkbench();
+        // or a site from within a editor or view:
+        // IServiceLocator serviceLocator = getSite();
+
+        ICommandService commandService = serviceLocator.getService(ICommandService.class);
+
+
+            // Lookup commmand with its ID
+            Command command = commandService.getCommand("org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createSession"); //$NON-NLS-1$
+
+            // Optionally pass a ExecutionEvent instance, default no-param arg creates blank event
+            try {
+                // execute new connection command directly
+                command.executeWithChecks(new ExecutionEvent());
+              // FIX THIS OH GOD THE INHUMANITY
+            } catch (Exception e) {
+
+                e.printStackTrace();
+            }
+
         return null;
     }
 
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/NewConnectionWizard.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/NewConnectionWizard.java
new file mode 100644 (file)
index 0000000..2d2527d
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Patrick-Jeffrey Pollo Guilbert - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+//import org.eclipse.swt.custom.CTabFolder;
+//import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.graphics.Color;
+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.Group;
+//import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.INewConnectionDialog;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.NewConnectionDialog;
+
+
+public class NewConnectionWizard {
+
+    static final int LABEL_WIDTH_CHARS = 4;
+    private NewConnectionDialog fNewConnectionDialog;
+
+    static final int CONNECTIONTREE_HEIGHT_CHARS = 10;
+    static final int CONNECTIONTREE_WIDTH_CHARS = 40;
+
+    TreeViewer fConnectionTree = null;
+    private CheckboxTreeViewer treeViewer;
+
+
+
+    // TODO: refactor name of class and all classes associated with it
+    public NewConnectionWizard()
+    {
+
+        Shell shell = new Shell();
+
+        shell.setLayout(new GridLayout());
+        Composite composite = new Composite(shell, SWT.BORDER);
+        Composite compositeDescription = new Composite(shell, SWT.BORDER);
+        composite.setBackground(new Color(null, 255,255,255));
+        compositeDescription.setBackground(new Color(null, 255,255,255));
+
+        GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
+        gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
+        gridData.horizontalSpan = 2;
+
+
+
+
+
+
+
+
+        Group groupProfile = new Group(composite, SWT.SHADOW_ETCHED_IN);
+        groupProfile.setText("Profiles List");
+
+
+        composite.setLayoutData(gridData);
+        composite.setLayout(new GridLayout(1, false));
+        groupProfile.setLayoutData(gridData);
+        groupProfile.setLayout(new GridLayout());
+        groupProfile.setBackground(new Color(null, 255,255,255));
+
+
+
+
+        new FilteredTree(groupProfile, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true){
+            @Override
+            protected TreeViewer doCreateTreeViewer(Composite aparent, int style) {
+                treeViewer = new CheckboxTreeViewer(aparent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+                //TODO: change string to one recorded in Messages class
+                treeViewer.getTree().setToolTipText("Select one or multiple profiles from the list below."); //$NON-NLS-1$
+                ArrayContentProvider test = new ArrayContentProvider();
+
+                treeViewer.setContentProvider(test);
+
+                test.inputChanged(treeViewer, null, new String[]{"allo", "bye"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+                treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+                return treeViewer;
+            }
+        };
+
+
+
+
+        // TODO: modify the checkbox addition to be based on availble profiles
+        Button b = new Button(groupProfile, SWT.CHECK);
+        b.setText("CPU Usage");
+        b.setBackground(new Color(null, 255,255,255));
+
+        Button b2 = new Button(groupProfile, SWT.CHECK);
+        b2.setText("Memory usage");
+        b2.setBackground(new Color(null, 255,255,255));
+
+        Button b3 = new Button(groupProfile, SWT.CHECK);
+        b3.setText("Disk Activity");
+        b3.setBackground(new Color(null, 255,255,255));
+
+
+        Group groupDescription = new Group(composite, SWT.SHADOW_ETCHED_IN);
+        groupDescription.setText("Description");
+
+        groupDescription.setLayoutData(gridData);
+        groupDescription.setLayout(new GridLayout());
+        groupDescription.setBackground(new Color(null, 255,255,255));
+
+
+        groupDescription.pack();
+
+        Label descriptionLabel = new Label(groupDescription, 0);
+        descriptionLabel.setText("No description available.");
+        descriptionLabel.setBackground(new Color(null, 255,255,255));
+
+        groupProfile.pack();
+
+        shell.open();
+
+
+    }
+
+    WizardPage wp = new ConnectionPage("Wizard");
+
+    protected void okPressed()
+    {
+
+    }
+
+    WizardPage testPage = new WizardPage("Kappa")
+    {
+
+        @Override
+        public void createControl(Composite parent) {
+            // TODO Auto-generated method stub
+            Composite canvas = new Composite(parent, SWT.NONE);
+            canvas.setLayout(new GridLayout());
+            this.setTitle("Session creation");
+
+            setControl(canvas);
+            Button b = new Button(canvas, SWT.RADIO);
+            b.setText("Local");
+
+        }
+
+    };
+
+    public INewConnectionDialog getfNewConnectionDialog() {
+        return fNewConnectionDialog;
+    }
+
+    public void setNewConnectionDialog(INewConnectionDialog fNewConnectionDialog) {
+        this.fNewConnectionDialog = (NewConnectionDialog) fNewConnectionDialog;
+    }
+
+    public CheckboxTreeViewer getTreeViewer() {
+        return treeViewer;
+    }
+
+    public void setTreeViewer(CheckboxTreeViewer treeViewer) {
+        this.treeViewer = treeViewer;
+    }
+
+}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/ProfileHandler.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/ProfileHandler.java
new file mode 100644 (file)
index 0000000..a3f6bea
--- /dev/null
@@ -0,0 +1,199 @@
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Patrick-Jeffrey Pollo Guilbert - Added headers, exporting .lttng profiles
+ *   William Enright - Added ProfileHandler implementation
+ *   William Tri-Khiem Truong - Completed documentation
+ **********************************************************************/
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.util.ArrayList;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteFileService;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.ProfileDialog;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup;
+import org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.handlers.IHandlerService;
+
+/**
+ * <p>
+ * Profile Handler to select and load session profiles for tracing purposes
+ * </p>
+ *
+ * @author William Tri-Khiem Truong, William Enright, Patrick-Jeffrey Pollo Guilbert
+ */
+public class ProfileHandler extends BaseControlViewHandler {
+
+    /**
+     * Id of the parameter for the remote services id.
+     *
+     * @see NewConnectionHandler
+     * @see IRemoteConnectionType#getId()
+     */
+    public static final String PARAMETER_REMOTE_SERVICES_ID = "org.eclipse.linuxtools.lttng2.control.ui.remoteServicesIdParameter"; //$NON-NLS-1$
+
+    /**
+     * (INewConnectionDialog) wd).getConnection() Id of the parameter for the
+     * name of the remote connection.
+     *
+     * @see NewConnectionHandler
+     * @see IRemoteConnectionType#getName()
+     */
+    public static final String PARAMETER_CONNECTION_NAME = "org.eclipse.linuxtools.lttng2.control.ui.connectionNameParameter"; //$NON-NLS-1$
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+
+        Shell s = new Shell(SWT.CENTER);
+
+        Rectangle screenSize = Display.getCurrent().getPrimaryMonitor().getBounds();
+        s.setLocation((screenSize.width - s.getBounds().width) / 2, (screenSize.height - s.getBounds().height) / 2);
+        s.setMinimumSize(500, 500);
+
+        IWorkbenchPage page = getWorkbenchPage();
+        if (page == null) {
+            return false;
+        }
+
+        TargetNodeComponent elementParent = null;
+
+        // Check if the session group project is selected
+        ISelection selection = page.getSelection(ControlView.ID);
+        if (selection instanceof StructuredSelection) {
+            Object element = ((StructuredSelection) selection).getFirstElement();
+            final TraceSessionGroup sessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
+            if (sessionGroup != null)
+            {
+                if (sessionGroup.getParent() instanceof TargetNodeComponent) {
+                    elementParent = (TargetNodeComponent) sessionGroup.getParent();
+                    final ProfileDialog btd = new ProfileDialog(s);
+                    if (btd.open() != Window.OK) {
+                        return null;
+                    }
+                    final String remotePath = sessionGroup.getTargetNode().getRemoteSystemProxy().getRemoteConnection().getProperty("user.home") + "/.lttng/sessions";  //$NON-NLS-1$//$NON-NLS-2$
+
+                    RemoteSystemProxy proxy = elementParent.getRemoteSystemProxy();
+                    IRemoteFileService fsss = proxy.getRemoteConnection().getService(IRemoteFileService.class);
+                    ArrayList<File> checkedFiles = btd.getCheckedFiles();
+
+                    for (File file : checkedFiles) {
+                        final IFileStore remoteFolder = fsss.getResource(remotePath);
+                        final IFileStore remoteFile = remoteFolder.getFileStore(new Path(file.getName()));
+                        try {
+                            try (OutputStream out = remoteFile.openOutputStream(EFS.NONE, new NullProgressMonitor()))
+                            {
+                                Files.copy(file.toPath(), out);
+                            }
+                        } catch (CoreException e) {
+                            e.printStackTrace();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+
+                        Job job = new Job(Messages.TraceControl_LoadSessionJob) {
+                            @Override
+                            protected IStatus run(IProgressMonitor monitor) {
+                                try {
+                                    sessionGroup.loadSession(remotePath + "/" + remoteFile.getName(), monitor); //$NON-NLS-1$
+                                } catch (ExecutionException e) {
+                                    return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_LoadSessionFailure, e);
+                                }
+                                return Status.OK_STATUS;
+                            }
+                        };
+
+                        job.setUser(true);
+                        job.schedule();
+                    }
+
+                }
+
+            }
+        }
+        // Refreshing the sessions in the control view by calling the refresh
+        // command
+
+        IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
+
+        IHandlerService service = part.getSite().getService(IHandlerService.class);
+
+        try {
+            service.executeCommand("org.eclipse.linuxtools.internal.lttng2.ui.commands.control.refresh", null); //$NON-NLS-1$
+        } catch (NotDefinedException e) {
+
+        } catch (NotEnabledException e) {
+
+        } catch (NotHandledException e) {
+
+        }
+        return null;
+    }
+
+    @Override
+    public boolean isEnabled() {
+
+        // Get workbench page for the Control View
+        IWorkbenchPage page = getWorkbenchPage();
+        if (page == null) {
+            return false;
+        }
+
+        TraceSessionGroup sessionGroup = null;
+
+        // Check if the session group project is selected
+        ISelection selection = page.getSelection(ControlView.ID);
+        if (selection instanceof StructuredSelection) {
+            Object element = ((StructuredSelection) selection).getFirstElement();
+            sessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
+        }
+
+        boolean isEnabled = sessionGroup != null;
+        fLock.lock();
+        try {
+            if (isEnabled) {
+            }
+        } finally {
+            fLock.unlock();
+        }
+        return isEnabled;
+    }
+}
\ No newline at end of file
index a935d19a53c246db06fe9465c5bbfea172810566..4f5cb91a219bd0c2b34bfda41fbdfa29def1ad91 100644 (file)
@@ -27,17 +27,14 @@ public final class Messages extends NLS {
 
     private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.messages"; //$NON-NLS-1$
 
-    public static String EnableChannelDialog_DefaultMessage;
-
-    public static String ImportHandler_LiveTraceElementError;
-
-    public static String ImportHandler_LiveTraceInitError;
-
     // Failures
     public static String TraceControl_ConnectionFailure;
     public static String TraceControl_DisconnectionFailure;
+    public static String TraceControl_LoadSessionFailure;
 
     public static String TraceControl_CommandError;
+    public static String ImportHandler_LiveTraceElementError;
+    public static String ImportHandler_LiveTraceInitError;
     public static String TraceControl_UnexpectedCommandOutputFormat;
     public static String TraceControl_UnexpectedNameError;
     public static String TraceControl_UnexpectedPathError;
@@ -73,6 +70,8 @@ public final class Messages extends NLS {
     public static String TraceControl_CreateSessionJob;
     public static String TraceControl_CreateSessionFailure;
 
+    public static String TraceControl_LoadSessionJob;
+
     public static String TraceControl_DestroySessionJob;
     public static String TraceControl_DestroySessionFailure;
     public static String TraceControl_DestroyConfirmationTitle;
@@ -88,6 +87,20 @@ public final class Messages extends NLS {
     public static String TraceControl_CreateChannelStateJob;
     public static String TraceControl_CreateChannelStateFailure;
 
+    public static String EnableChannelDialog_DefaultMessage;
+
+
+    public static String NoSelectionDescription;
+
+
+    public static String ProfileDialog_5;
+
+
+    public static String ProfileDialog_6;
+
+
+    public static String ProfileDialog_LTTNG_Suffix;
+
     public static String TraceControl_ChangeChannelStateJob;
     public static String TraceControl_ChangeChannelStateFailure;
     public static String TraceControl_ChangeEventStateJob;
@@ -165,6 +178,9 @@ public final class Messages extends NLS {
     public static String TraceControl_CreateSessionLiveDelayTooltip;
 
     public static String TraceControl_InvalidSessionNameError;
+    public static String TraceControl_SelectBasicProfile;
+
+
     public static String TraceControl_SessionAlreadyExistsError;
     public static String TraceControl_SessionPathAlreadyExistsError;
     public static String TraceControl_InvalidSessionPathError;
@@ -276,7 +292,13 @@ public final class Messages extends NLS {
     public static String TraceControl_OverwriteModePropertyName;
     public static String TraceControl_SubBufferSizePropertyName;
     public static String TraceControl_NbSubBuffersPropertyName;
+
+
+    public static String TraceControl_NoProfileSelected;
     public static String TraceControl_SwitchTimerPropertyName;
+    public static String TraceControl_ReadingPathError;
+
+
     public static String TraceControl_ReadTimerPropertyName;
     public static String TraceControl_OutputTypePropertyName;
     public static String TraceControl_TraceFileCountPropertyName;
@@ -284,6 +306,9 @@ public final class Messages extends NLS {
     public static String TraceControl_HostNamePropertyName;
     public static String TraceControl_HostAddressPropertyName;
     public static String TraceControl_SessionPathPropertyName;
+
+
+    public static String TraceControl_SingleSelectionDescription;
     public static String TraceControl_SnapshotPathPropertyName;
     public static String TraceControl_SnapshotNamePropertyName;
     public static String TraceControl_SnapshotIdPropertyName;
@@ -294,12 +319,18 @@ public final class Messages extends NLS {
     public static String TraceControl_ProbeSymbolPropertyName;
     public static String TraceControl_MaxSizeTraceFilesPropertyName;
     public static String TraceControl_MaxNumTraceFilesPropertyName;
+
+
+    public static String TraceControl_MultipleSelectionDescription;
     public static String TraceControl_ConfigureMetadataChannelName;
 
     // Preferences
     public static String TraceControl_TracingGroupPreference;
     public static String TraceControl_LoggingPreference;
     public static String TraceControl_LogfilePath;
+
+
+    public static String TraceControl_LttngSuffix;
     public static String TraceControl_AppendLogfilePreference;
 
     public static String TraceControl_VerboseLevelsPreference;
@@ -317,6 +348,8 @@ public final class Messages extends NLS {
 
     public static String TraceControl_UnknownNode;
 
+    public static String TraceControl_BasicMode;
+
     static {
         // initialize resource bundle
         NLS.initializeMessages(BUNDLE_NAME, Messages.class);
index 099c66b8296f5138ebe821313ce0f054ff7be868..55e9f873e3dfd038ff3b2e86168b0bb4b663e6dd 100644 (file)
 EnableChannelDialog_DefaultMessage=Default
 ImportHandler_LiveTraceElementError=Could not find trace element
 ImportHandler_LiveTraceInitError=Error initializing live trace.
+NoSelectionDescription="No profile was checked"
+ProfileDialog_5=
+ProfileDialog_6=
+ProfileDialog_LTTNG_Suffix=
 TraceControl_ConnectionFailure=Connecting to host failed 
 TraceControl_DisconnectionFailure=Disconnection from host failed
 TraceControl_CommandError=Command failed! Command: 
@@ -26,6 +30,7 @@ TraceControl_UnexpectedValueError=Unexpected value. Returned {0} Expected: {1}
 
 TraceControl_UnsupportedVersionError=Unsupported LTTng Tracer Control version
 TraceControl_GettingVersionError=Could not get version of LTTng Tracer Control
+TraceControl_BasicMode=Basic mode
 
 # Xml parsing related failures
 TraceControl_InvalidSchemaError=Could not open/validate xsd Schema
@@ -52,6 +57,8 @@ TraceControl_NewNodeCreateButtonText=Create...
 TraceControl_NewNodeCreationFailure=Creation of new connection failed
 TraceControl_CreateSessionJob=Creating Session...
 TraceControl_CreateSessionFailure=Command to create session failed
+TraceControl_LoadSessionJob=Loading Session...
+TraceControl_LoadSessionFailure=Command to load session failed
 
 TraceControl_DestroySessionJob=Destroying Session...
 TraceControl_DestroySessionFailure=Command to destroy session failed
@@ -151,6 +158,7 @@ TraceControl_CreateSessionLiveConnectionUrlTooltip=The URL for the live connecti
 TraceControl_CreateSessionLiveConnectionPortTooltip=The port for the live connection (Relayd)
 
 TraceControl_InvalidSessionNameError=The session name is invalid
+TraceControl_SelectBasicProfile=Select your basic tracing profile and connection type.
 TraceControl_SessionAlreadyExistsError=The session name already exists
 TraceControl_SessionPathAlreadyExistsError=Session path already exists
 TraceControl_InvalidSessionPathError=The session path is invalid
@@ -261,7 +269,9 @@ TraceControl_OpenConnectionTo=Opening connection to ''{0}''
 TraceControl_OverwriteModePropertyName=Overwrite Mode
 TraceControl_SubBufferSizePropertyName=Sub Buffer Size
 TraceControl_NbSubBuffersPropertyName=Number of Sub Buffers
+TraceControl_NoProfileSelected=No profile was selected. No description available.
 TraceControl_SwitchTimerPropertyName=Switch Timer Interval
+TraceControl_ReadingPathError=Error reading file in path %s\n
 TraceControl_ReadTimerPropertyName=Read Timer Interval
 TraceControl_OutputTypePropertyName=Output Type
 TraceControl_TraceFileCountPropertyName=Trace File Count
@@ -269,6 +279,7 @@ TraceControl_TraceFileSizePropertyName=Trace File Size
 TraceControl_HostNamePropertyName=Connection Name
 TraceControl_HostAddressPropertyName=Host Name
 TraceControl_SessionPathPropertyName=Session Path
+TraceControl_SingleSelectionDescription=A profile was selected, but no description was found within the profile.
 TraceControl_SnapshotPathPropertyName=Snapshot Path
 TraceControl_SnapshotNamePropertyName=Snapshot Name
 TraceControl_SnapshotIdPropertyName=Snapshot ID
@@ -279,12 +290,14 @@ TraceControl_ProbeOffsetPropertyName=Offset
 TraceControl_ProbeSymbolPropertyName=Symbol
 TraceControl_MaxSizeTraceFilesPropertyName=Maximum size of trace files
 TraceControl_MaxNumTraceFilesPropertyName=Maximum number of trace files
+TraceControl_MultipleSelectionDescription=This configuration will attempt to trace with multiple profil1es simultaneously.
 TraceControl_ConfigureMetadataChannelName=Configure metadata channel
 
 # Preferences
 TraceControl_TracingGroupPreference=&Tracing Group
 TraceControl_LoggingPreference=&Logging
 TraceControl_LogfilePath=Log file
+TraceControl_LttngSuffix=.lttng
 TraceControl_AppendLogfilePreference=&Append
 TraceControl_VerboseLevelsPreference=&Verbose Level
 TraceControl_VerboseLevelNonePreference=None
index bbb1af306d09a4950b5af70d676d5c206fab148c..48b8a99a4bc7cf73c485dca53e3d8f90b5a52070 100644 (file)
@@ -142,4 +142,9 @@ class NullControlService implements ILttngControlService {
     @Override
     public void runCommands(IProgressMonitor monitor, List<String> commands) throws ExecutionException {
     }
+
+    @Override
+    public void loadSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+
+    }
 }
index ca91f58eb6e08f7efe7033d4c645b4d4d81990a7..425a1d8673e9e0597ee9b56498995925dd1f4159 100644 (file)
@@ -141,6 +141,22 @@ public class TraceSessionGroup extends TraceControlComponent {
         }
     }
 
+    /**
+     * Loads a session from a path
+     *
+     * @param sessionPath
+     *
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    public void loadSession(String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+       getControlService().loadSession(sessionPath, monitor);
+
+
+    }
+
     /**
      * Command to execute a list of commands
      * @param monitor
index 81d9bd51c2a78a5ed02fbcaead4260d0f52e640a..2a0da6c5cf6042db56bd204d165e631e0b989a6a 100644 (file)
@@ -400,4 +400,18 @@ public interface ILttngControlService {
      */
     void runCommands(IProgressMonitor monitor, List<String> commands)
             throws ExecutionException;
+
+    /**
+     * Load a session with given session name.
+     *
+     * @param sessionName
+     *            - a session name to start
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    void loadSession(String sessionName, IProgressMonitor monitor)
+            throws ExecutionException;
+
 }
index ba3f32317f71de5c249a12731d991598dfc72538..7fd436453b36940f14bf5b1d8e2c41fdf6f87c92 100644 (file)
@@ -668,6 +668,16 @@ public class LTTngControlService implements ILttngControlService {
 
     }
 
+    @Override
+    public void loadSession(String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+
+        ICommandInput command = createCommand(LTTngControlServiceConstants.COMMAND_LOAD_SESSION, "-i", sessionPath); //$NON-NLS-1$
+
+        executeCommand(command, monitor);
+
+        // Session <sessionName> loaded
+    }
+
     @Override
     public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
 
@@ -1535,4 +1545,6 @@ public class LTTngControlService implements ILttngControlService {
 
         return result;
     }
+
+
 }
index 7190e78631a1e67aa3551290cdb5514da8445835..20060280a6714a664a0ca817c073e65d1451d536 100644 (file)
@@ -94,6 +94,10 @@ public interface LTTngControlServiceConstants {
      * Command to destroy a session.
      */
     String COMMAND_START_SESSION = "start"; //$NON-NLS-1$
+    /**
+     * Command to load a session.
+     */
+    String COMMAND_LOAD_SESSION = "load"; //$NON-NLS-1$
     /**
      * Command to destroy a session.
      */
This page took 0.048969 seconds and 5 git commands to generate.