aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrajesh2014-01-28 13:38:00 (EST)
committerRodrigo Fraxino Araujo2014-02-04 08:38:05 (EST)
commitdb676a61a756e662bb00c81ec59d92b105a4eb26 (patch)
tree60f06643ae88403c40cd0a5d0e2935bf188218f9
parent5b70c50b1a0394da497b95568056333a4de30aca (diff)
downloadorg.eclipse.linuxtools-db676a61a756e662bb00c81ec59d92b105a4eb26.zip
org.eclipse.linuxtools-db676a61a756e662bb00c81ec59d92b105a4eb26.tar.gz
org.eclipse.linuxtools-db676a61a756e662bb00c81ec59d92b105a4eb26.tar.bz2
oprofile: improve support for multiple eventsrefs/changes/17/21217/6
this patch solve two usability issue. 1.Having session as root element in oprofile tree view. 2.Improve event tab UI for multiple event selection by adding one more list viewer for all selected events. Now Operf/Opcontrol just have one tab. in case of Opcontrol events counts is restricted to number of hardware counter. for operf is not limited to counters. customize button now will be enabled on selection of events in both list. Change-Id: I86da6015d8354ed0431e9623af63773de72850f3 Signed-off-by: Brajesh <brrathor@linux.vnet.ibm.com> Reviewed-on: https://git.eclipse.org/r/21217 Tested-by: Hudson CI Reviewed-by: Rodrigo Fraxino Araujo <rfaraujo@linux.vnet.ibm.com> IP-Clean: Rodrigo Fraxino Araujo <rfaraujo@linux.vnet.ibm.com> Tested-by: Rodrigo Fraxino Araujo <rfaraujo@linux.vnet.ibm.com>
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core.tests/resources/test_sessions.xml16
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestDataModel.java10
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestSessionsParse.java61
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java18
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java15
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpxmlProvider.java38
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java58
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelRoot.java58
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelSession.java51
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java145
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java34
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java569
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties15
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent.java (renamed from oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession.java)16
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent2.java (renamed from oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession2.java)16
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent3.java (renamed from oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession3.java)16
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent4.java (renamed from oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession4.java)10
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelRoot.java36
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui.tests/src/org/eclipse/linuxtools/oprofile/ui/tests/TestUiDataModel.java166
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF1
-rwxr-xr-xoprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java11
-rwxr-xr-xoprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java45
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelEvent.java35
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java24
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java38
25 files changed, 1027 insertions, 475 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core.tests/resources/test_sessions.xml b/oprofile/org.eclipse.linuxtools.oprofile.core.tests/resources/test_sessions.xml
index 2c3016d..6640df7 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core.tests/resources/test_sessions.xml
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core.tests/resources/test_sessions.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<sessions>
- <event name="BR_INST_EXEC">
+ <!-- <event name="BR_INST_EXEC">
<session name="current">
</session>
</event>
@@ -13,6 +13,18 @@
</session>
<session name="&quot;&lt;&gt;&amp;&apos;">
</session>
- </event>
+ </event> -->
+ <session name="current">
+ <event name="BR_INST_EXEC"/>
+ <event name="UOPS_RETIRED"/>
+ </session>
+
+ <session name="saved">
+ <event name="CPU_CLK_UNHALTED"/>
+ </session>
+
+ <session name="&quot;&lt;&gt;&amp;&apos;">
+ <event name="UOPS_RETIRED"/>
+ </session>
</sessions>
\ No newline at end of file
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestDataModel.java b/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestDataModel.java
index d4715c5..89ab49b 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestDataModel.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestDataModel.java
@@ -30,12 +30,12 @@ public class TestDataModel {
@Test
public void testParse() {
- OpModelEvent[] events = _testRoot.getEvents();
- assertEquals(3, events.length);
- assertEquals(TestingOpModelRoot.NAME_E1, events[0].getName());
- assertEquals(TestingOpModelRoot.NAME_E2, events[1].getName());
+ OpModelSession[] sessions = _testRoot.getSessions();
+ assertEquals(3, sessions.length);
+ assertEquals(TestingOpModelRoot.NAME_E1, sessions[0].getName());
+ assertEquals(TestingOpModelRoot.NAME_E2, sessions[1].getName());
- OpModelSession[] e1_sessions = events[0].getSessions(), e2_sessions = events[1].getSessions();
+ OpModelEvent[] e1_sessions = sessions[0].getEvents(), e2_sessions = sessions[1].getEvents();
assertEquals(1, e1_sessions.length);
assertEquals(4, e2_sessions.length);
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestSessionsParse.java b/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestSessionsParse.java
index 453b50c..8f72652 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestSessionsParse.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core.tests/src/org/eclipse/linuxtools/oprofile/core/tests/TestSessionsParse.java
@@ -32,20 +32,20 @@ import org.xml.sax.XMLReader;
public class TestSessionsParse {
private static final String REL_PATH_TO_TEST_XML = "resources/test_sessions.xml"; //$NON-NLS-1$
- private static final String EVENT1_OUTPUT = "BR_INST_EXEC\nSession: current\n"; //$NON-NLS-1$
- private static final String EVENT1_OUTPUT_WITHTAB = "BR_INST_EXEC\n\tSession: current\n"; //$NON-NLS-1$
- private static final String EVENT2_OUTPUT = "CPU_CLK_UNHALTED\nSession: saved\n"; //$NON-NLS-1$
- private static final String EVENT2_OUTPUT_WITHTAB = "CPU_CLK_UNHALTED\n\tSession: saved\n"; //$NON-NLS-1$
- private static final String EVENT3_OUTPUT = "UOPS_RETIRED\nSession: current\nSession: \"<>&'\n"; //$NON-NLS-1$
- private static final String EVENT3_OUTPUT_WITHTAB = "UOPS_RETIRED\n\tSession: current\n\tSession: \"<>&'\n"; //$NON-NLS-1$
+ private static final String EVENT1_OUTPUT = "current\nEvent: BR_INST_EXEC\nEvent: UOPS_RETIRED\n"; //$NON-NLS-1$
+ private static final String EVENT1_OUTPUT_WITHTAB = "current\n\tEvent: BR_INST_EXEC\n\tEvent: UOPS_RETIRED\n"; //$NON-NLS-1$
+ private static final String EVENT2_OUTPUT = "saved\nEvent: CPU_CLK_UNHALTED\n"; //$NON-NLS-1$
+ private static final String EVENT2_OUTPUT_WITHTAB = "saved\n\tEvent: CPU_CLK_UNHALTED\n"; //$NON-NLS-1$
+ private static final String EVENT3_OUTPUT = "\"<>&'\nEvent: UOPS_RETIRED\n"; //$NON-NLS-1$
+ private static final String EVENT3_OUTPUT_WITHTAB = "\"<>&'\n\tEvent: UOPS_RETIRED\n"; //$NON-NLS-1$
- private ArrayList<OpModelEvent> eventList;
+ private ArrayList<OpModelSession> eventList;
@Before
public void setUp() throws Exception {
/* this code mostly taken from OpxmlRunner */
XMLReader reader = null;
- eventList = new ArrayList<>();
+ eventList = new ArrayList<OpModelSession>();
SessionsProcessor.SessionInfo sessioninfo = new SessionsProcessor.SessionInfo(eventList);
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(sessioninfo);
@@ -64,44 +64,35 @@ public class TestSessionsParse {
@Test
public void testParse() {
assertEquals(3, eventList.size());
- OpModelEvent evt1 = eventList.get(0), evt2 = eventList.get(1), evt3 = eventList.get(2);
+ OpModelEvent evt1 = eventList.get(0).getEvents()[0], evt2 = eventList.get(1).getEvents()[0], evt3 = eventList.get(2).getEvents()[0];
assertEquals("BR_INST_EXEC", evt1.getName()); //$NON-NLS-1$
assertEquals("CPU_CLK_UNHALTED", evt2.getName()); //$NON-NLS-1$
assertEquals("UOPS_RETIRED", evt3.getName()); //$NON-NLS-1$
- OpModelSession[] evt1_ss = evt1.getSessions(), evt2_ss = evt2.getSessions(), evt3_ss = evt3.getSessions();
- assertEquals(1, evt1_ss.length);
- assertEquals(1, evt2_ss.length);
- assertEquals(2, evt3_ss.length);
- OpModelSession evt1_ss_s1 = evt1_ss[0];
- OpModelSession evt2_ss_s1 = evt2_ss[0];
- OpModelSession evt3_ss_s1 = evt3_ss[0];
- OpModelSession evt3_ss_s2 = evt3_ss[1];
+
+ OpModelSession evt1_ss_s1 = evt1.getSession();
+ OpModelSession evt2_ss_s1 = evt2.getSession();
+ OpModelSession evt3_ss_s1 = evt3.getSession();
+
assertEquals("current", evt1_ss_s1.getName()); //$NON-NLS-1$
assertEquals(true, evt1_ss_s1.isDefaultSession());
- assertNull(evt1_ss_s1.getImage());
- assertEquals(0, evt1_ss_s1.getCount());
- assertEquals(evt1, evt1_ss_s1.getEvent());
+ assertNull(evt1.getImage());
+ assertEquals(0, evt1.getCount());
+ assertEquals(evt1, evt1_ss_s1.getEvents()[0]);
assertEquals("saved", evt2_ss_s1.getName()); //$NON-NLS-1$
assertEquals(false, evt2_ss_s1.isDefaultSession());
- assertNull(evt2_ss_s1.getImage());
- assertEquals(0, evt2_ss_s1.getCount());
- assertEquals(evt2, evt2_ss_s1.getEvent());
-
- assertEquals("current", evt3_ss_s1.getName()); //$NON-NLS-1$
- assertEquals(true, evt3_ss_s1.isDefaultSession());
- assertNull(evt3_ss_s1.getImage());
- assertEquals(0, evt3_ss_s1.getCount());
- assertEquals(evt3, evt3_ss_s1.getEvent());
-
- assertEquals("\"<>&'", evt3_ss_s2.getName()); //$NON-NLS-1$
- assertEquals(false, evt3_ss_s2.isDefaultSession());
- assertNull(evt3_ss_s2.getImage());
- assertEquals(0, evt3_ss_s2.getCount());
- assertEquals(evt3, evt3_ss_s2.getEvent());
+ assertNull(evt2.getImage());
+ assertEquals(0, evt2.getCount());
+ assertEquals(evt2, evt2_ss_s1.getEvents()[0]);
+
+ assertEquals("\"<>&'", evt3_ss_s1.getName()); //$NON-NLS-1$
+ assertEquals(false, evt3_ss_s1.isDefaultSession());
+ assertNull(evt3.getImage());
+ assertEquals(0, evt3.getCount());
+ assertEquals(evt3, evt3_ss_s1.getEvents()[0]);
}
@Test
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java
index e398bad..b5aab4d 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java
@@ -7,30 +7,30 @@
*
* Contributors:
* Keith Seitz <keiths@redhat.com> - initial API and implementation
- * Kent Sebastian <ksebasti@redhat.com> -
- *******************************************************************************/
+ * Kent Sebastian <ksebasti@redhat.com> -
+ *******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.core;
import java.util.ArrayList;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpInfo;
-import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
/**
* Interface for the core to utilize opxml. Platform plugins should define/register an
* OpxmlProvider for the core to use.
*/
public interface IOpxmlProvider {
-
+
/**
* Returns an <code>IRunnableWithProgress</code> that fetches generic information from opxml
* @param info <code>OpInfo</code> object for results
* @return <code>IRunnableWithProgress</code> that may be run by the caller
*/
public IRunnableWithProgress info(OpInfo info);
-
+
/**
* Returns an <code>IRunnableWithProgress</code> that fetches samples for the
* given <code>OpModelSession</code>
@@ -40,10 +40,10 @@ public interface IOpxmlProvider {
* @return <code>IRunnableWithProgress</code> that may be run by the caller
*/
public IRunnableWithProgress modelData(String eventName, String sessionName, OpModelImage image);
-
+
/**
* Returns an <code>IRunnableWithProgress</code> that checks the validity of the given
- * event, unit mask, and counter combination
+ * event, unit mask, and counter combination
* @param ctr the counter
* @param event the String event name
* @param um the integer unit mask
@@ -51,12 +51,12 @@ public interface IOpxmlProvider {
* @return <code>IRunnableWithProgress</code> that may be run by the caller
*/
public IRunnableWithProgress checkEvents(int ctr, String event, int um, int[] eventValid);
-
+
/**
* Returns an <code>IRunnableWithProgress</code> that fetches the list of sessions
* @param info the <code>OpInfo</code> for oprofile
* @param sessionList an <code>ArrayList</code> in which to return the list of sessions
* @return <code>IRunnableWithProgress</code> that may be run by the caller
*/
- public IRunnableWithProgress sessions(ArrayList<OpModelEvent> sessionList);
+ public IRunnableWithProgress sessions(ArrayList<OpModelSession> sessionList);
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java
index 23e88ee..11f894e 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java
@@ -22,8 +22,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpInfo;
-import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.checkevent.CheckEventsProcessor;
import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
@@ -221,18 +221,19 @@ public class Oprofile
}
/**
- * Returns a list of all the events collected on the system, as well as
- * the sessions under each of them.
+ * Returns a list of all the session collected on the system, as well as
+ * the event under each of them.
+ * @since 3.0
* @returns a list of all collected events
*/
- public static OpModelEvent[] getEvents() {
- OpModelEvent[] events = null;
+ public static OpModelSession[] getSessions() {
+ OpModelSession[] events = null;
- ArrayList<OpModelEvent> sessionList = new ArrayList<>();
+ ArrayList<OpModelSession> sessionList = new ArrayList<OpModelSession>();
try {
IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().sessions(sessionList);
opxml.run(null);
- events = new OpModelEvent[sessionList.size()];
+ events = new OpModelSession[sessionList.size()];
sessionList.toArray(events);
} catch (InvocationTargetException e) {
} catch (InterruptedException e) {
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpxmlProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpxmlProvider.java
index 5f7724c..8e38a88 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpxmlProvider.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpxmlProvider.java
@@ -7,8 +7,8 @@
*
* Contributors:
* Keith Seitz <keiths@redhat.com> - initial API and implementation
- * Kent Sebastian <ksebasti@redhat.com>
- *******************************************************************************/
+ * Kent Sebastian <ksebasti@redhat.com>
+ *******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.core.linux;
import java.lang.reflect.InvocationTargetException;
@@ -18,8 +18,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.linuxtools.internal.oprofile.core.IOpxmlProvider;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpInfo;
-import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.OpxmlConstants;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.modeldata.ModelDataProcessor;
import org.eclipse.linuxtools.internal.oprofile.core.opxml.sessions.SessionsProcessor;
@@ -28,7 +28,7 @@ import org.eclipse.linuxtools.internal.oprofile.core.opxml.sessions.SessionsProc
* A class which implements the IOpxmlProvider interface for running opxml.
*/
public class LinuxOpxmlProvider implements IOpxmlProvider {
-
+
@Override
public IRunnableWithProgress info(final OpInfo info) {
return new OpInfoRunner(info);
@@ -38,16 +38,16 @@ public class LinuxOpxmlProvider implements IOpxmlProvider {
public class OpInfoRunner implements IRunnableWithProgress {
private boolean b;
final private OpInfo info;
-
+
public OpInfoRunner(OpInfo info) {
this.info = info;
}
-
+
public boolean run0(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
run(monitor);
return b;
}
-
+
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
OpxmlRunner runner = new OpxmlRunner();
@@ -57,10 +57,10 @@ public class LinuxOpxmlProvider implements IOpxmlProvider {
b = runner.run(args, info);
}
}
-
+
@Override
public IRunnableWithProgress modelData(final String eventName, final String sessionName, final OpModelImage image) {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
OpxmlRunner runner = new OpxmlRunner();
@@ -70,15 +70,15 @@ public class LinuxOpxmlProvider implements IOpxmlProvider {
eventName,
sessionName
};
-
+
ModelDataProcessor.CallData data = new ModelDataProcessor.CallData(image);
runner.run(args, data);
}
};
-
+
return runnable;
}
-
+
@Override
public IRunnableWithProgress checkEvents(final int ctr, final String event, final int um, final int[] eventValid) {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@@ -91,16 +91,20 @@ public class LinuxOpxmlProvider implements IOpxmlProvider {
event,
Integer.toString(um)
};
-
+
runner.run(args, eventValid);
}
};
return runnable;
}
-
+
+ /**
+ * return list of session collected on this system as well as events under each of them.
+ * @since 3.0
+ */
@Override
- public IRunnableWithProgress sessions(final ArrayList<OpModelEvent> sessionList) {
-
+ public IRunnableWithProgress sessions(final ArrayList<OpModelSession> sessionList) {
+
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) {
@@ -108,7 +112,7 @@ public class LinuxOpxmlProvider implements IOpxmlProvider {
String[] args = new String[] {
OpxmlConstants.OPXML_SESSIONS,
};
-
+
SessionsProcessor.SessionInfo sinfo = new SessionsProcessor.SessionInfo(sessionList);
runner.run(args, sinfo);
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java
index abafa4f..4e4a934 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java
@@ -12,39 +12,57 @@
package org.eclipse.linuxtools.internal.oprofile.core.model;
+import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
+
/**
* A class which represents the event collected in a given session.
*/
public class OpModelEvent {
private String eventName;
- private OpModelSession[] sessions;
private String printTabs = ""; //for nice output //$NON-NLS-1$
-
- public OpModelEvent(String name) {
- eventName = name;
- }
+ private OpModelImage image;
+ private OpModelSession parentSession;
- public OpModelSession[] getSessions() {
- return sessions;
- }
- public void setSessions(OpModelSession[] sessions) {
- this.sessions = sessions;
+ public OpModelEvent(OpModelSession parentSession ,String name) {
+ this.parentSession = parentSession;
+ this.eventName = name;
}
public String getName() {
return eventName;
}
- //populate all sessions
+ public OpModelSession getSession()
+ {
+ return parentSession;
+ }
+
+ public void setSession(OpModelSession session)
+ {
+ this.parentSession = session;
+ }
+ //populate all images & dependent images
public void refreshModel() {
- if (sessions != null) {
- for (int i = 0; i < sessions.length; i++) {
- sessions[i].refreshModel();
- }
+ image = getNewImage();
+ }
+
+ public OpModelImage getImage() {
+ return image;
+ }
+
+ protected OpModelImage getNewImage() {
+ return Oprofile.getModelData(this.eventName, parentSession.getName());
+ }
+
+ public int getCount() {
+ if (image == null) {
+ return 0;
+ } else {
+ return image.getCount();
}
}
-
+
public String toString(String tabs) {
printTabs = tabs;
String s = toString();
@@ -55,11 +73,9 @@ public class OpModelEvent {
@Override
public String toString() {
String s = eventName + "\n"; //$NON-NLS-1$
- if (sessions != null) {
- for (int i = 0; i < sessions.length; i++) {
- s += printTabs + "Session: "; //$NON-NLS-1$
- s += sessions[i].toString(printTabs + "\t"); //$NON-NLS-1$
- }
+ if (image != null) {
+ s += printTabs + "Image: "; //$NON-NLS-1$
+ s += image.toString(printTabs + "\t"); //$NON-NLS-1$
}
return s;
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelRoot.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelRoot.java
index 88a0d37..66ad732 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelRoot.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelRoot.java
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
- *******************************************************************************/
+ * Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
+ *******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.core.model;
@@ -16,21 +16,21 @@ import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
/**
* A root node for the data model. Only one instance exists at any time,
* although the contents will change. On instantiation the events and
- * sessions are gathered.
- *
+ * sessions are gathered.
+ *
* Note that this data model does not map 1:1 to the oprofile data model.
* This model is for use in profiling one application compiled with debug
- * info, from within eclipse.
+ * info, from within eclipse.
*/
public class OpModelRoot {
//single instance
private static OpModelRoot modelRoot = new OpModelRoot();
- private OpModelEvent[] events;
+ private OpModelSession[] session;
protected OpModelRoot() {
- events = null;
+ session = null;
}
public static OpModelRoot getDefault() {
@@ -39,34 +39,40 @@ public class OpModelRoot {
public void refreshModel() {
//TODO-performance/interactivity: some persistence for events/sessions
- // that dont change from run to run (non default sessions)
-
- events = getNewEvents();
- if (events != null) {
- for (int i = 0; i < events.length; i++) {
- if (events[i] != null)
- events[i].refreshModel();
+ // that dont change from run to run (non default sessions)
+
+ session = getNewSessions();
+ if (session != null) {
+ for (int i = 0; i < session.length; i++) {
+ if (session[i] != null)
+ session[i].refreshModel();
}
}
}
-
- protected OpModelEvent[] getNewEvents() {
+
+ /**
+ * return list of session collected on this system as well as events under each of them.
+ * @return collected sessions list
+ * @since 3.0
+ */
+ protected OpModelSession[] getNewSessions() {
//launch `opxml sessions`, gather up events & the sessions under them
- return Oprofile.getEvents();
+ return Oprofile.getSessions();
}
-
- public OpModelEvent[] getEvents() {
- return events;
+
+
+ public OpModelSession[] getSessions() {
+ return session;
}
-
+
@Override
public String toString() {
String s = ""; //$NON-NLS-1$
- if (events != null) {
- for (int i = 0; i < events.length; i++) {
- if (events[i] != null) {
- s += "Event: "; //$NON-NLS-1$
- s += events[i].toString("\t"); //$NON-NLS-1$
+ if (session != null) {
+ for (int i = 0; i < session.length; i++) {
+ if (session[i] != null) {
+ s += "Session: "; //$NON-NLS-1$
+ s += session[i].toString("\t"); //$NON-NLS-1$
}
}
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelSession.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelSession.java
index bbf7eb5..17e6f9d 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelSession.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelSession.java
@@ -11,7 +11,6 @@
package org.eclipse.linuxtools.internal.oprofile.core.model;
-import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
/**
@@ -21,35 +20,26 @@ import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
public class OpModelSession {
private static final String DEFAULT_SESSION_STRING = "current"; //$NON-NLS-1$
- private OpModelEvent parentEvent;
- private OpModelImage image;
private String name;
private String printTabs = ""; //for nice output //$NON-NLS-1$
+ private OpModelEvent[] events;
- public OpModelSession(OpModelEvent event, String name) {
- parentEvent = event;
+ public OpModelSession(String name) {
this.name = name;
- image = null;
- }
-
- public OpModelImage getImage() {
- return image;
}
- public OpModelEvent getEvent() {
- return parentEvent;
- }
-
+
public String getName() {
return name;
}
-
- public int getCount() {
- if (image == null) {
- return 0;
- } else {
- return image.getCount();
- }
+
+ public OpModelEvent[] getEvents() {
+ return events;
+ }
+
+
+ public void setEvents(OpModelEvent[] events) {
+ this.events = events;
}
public boolean isDefaultSession() {
@@ -57,12 +47,11 @@ public class OpModelSession {
}
public void refreshModel() {
- //populate this session with samples
- image = getNewImage();
- }
-
- protected OpModelImage getNewImage() {
- return Oprofile.getModelData(parentEvent.getName(), name);
+ if (events != null) {
+ for (int i = 0; i < events.length; i++) {
+ events[i].refreshModel();
+ }
+ }
}
public String toString(String tabs) {
@@ -75,9 +64,11 @@ public class OpModelSession {
@Override
public String toString() {
String s = name + "\n"; //$NON-NLS-1$
- if (image != null) {
- s += printTabs + "Image: "; //$NON-NLS-1$
- s += image.toString(printTabs + "\t"); //$NON-NLS-1$
+ if (events != null) {
+ for (int i = 0; i < events.length; i++) {
+ s += printTabs + "Event: "; //$NON-NLS-1$
+ s += events[i].toString(printTabs + "\t"); //$NON-NLS-1$
+ }
}
return s;
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java
index 45a1b98..a1c18f3 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java
@@ -48,19 +48,19 @@ public class SessionManager {
public final static String OPXML_PREFIX = PLUGIN_LOC + "/opxml_"; //$NON-NLS-1$
public final static String SESSION_LOCATION = OPXML_PREFIX + SESSIONS; //$NON-NLS-1$
public final static String MODEL_DATA = "model-data"; //$NON-NLS-1$
-
+
public Document doc;
public Element root;
public String absfilePath;
-
+
public SessionManager(String filePath) {
this(new File(filePath));
absfilePath = filePath;
write();
}
-
+
/**
- * Session manager class constructor to manipulate the XML data
+ * Session manager class constructor to manipulate the XML data
* @param file the xml file
*/
public SessionManager(File file) {
@@ -87,27 +87,29 @@ public class SessionManager {
e.printStackTrace();
}
}
-
+
/**
* Add a session to the specified event element if it does not exist.
* @param sessionName the name of the session
* @param eventName the name of the event
*/
public void addSession(String sessionName, String eventName){
- Element event = find(root, EVENT, NAME, eventName);
-
- Element session = doc.createElement(SESSION);
- session.setAttribute(NAME, sessionName);
-
+ Element event = null;
+ Element session = find(root, SESSION, NAME, sessionName);
+ if(session == null){
+ session = doc.createElement(SESSION);
+ session.setAttribute(NAME, sessionName);
+ root.appendChild(session);
+ }
+ else
+ event = find(session, EVENT, NAME, eventName);
+
+
if (event == null){
event = doc.createElement(EVENT);
event.setAttribute(NAME, eventName);
- root.appendChild(event);
- event.appendChild(session);
- }else{
- if (find (event, SESSION, NAME, sessionName) == null){
- event.appendChild(session);
- }
+ session.appendChild(event);
+
}
}
/**
@@ -118,7 +120,7 @@ public class SessionManager {
public boolean existsSession (String sessionName){
return find (root, SESSION, NAME, sessionName) != null ? true : false;
}
-
+
/**
* Find an element in the XML
* @param elem the element to look under
@@ -139,57 +141,83 @@ public class SessionManager {
}
return null;
}
-
+
/**
* Remove all sessions under any event that have the name 'current'
*/
public void removeAllCurrentSessions() {
- NodeList eventList = root.getElementsByTagName(EVENT);
- for (int i = 0; i < eventList.getLength(); i++){
- Element event = (Element) eventList.item(i);
- String eventName = event.getAttribute(NAME);
- NodeList sessionList = event.getElementsByTagName(SESSION);
- for (int j = 0; j < sessionList.getLength(); j++){
- Element session = (Element) sessionList.item(j);
- if (session.getAttribute(NAME).equals(CURRENT)){
- event.removeChild(session);
- File file = new File (SessionManager.OPXML_PREFIX + SessionManager.MODEL_DATA + eventName + SessionManager.CURRENT);
- file.delete();
- if (sessionList.getLength() == 0){
- root.removeChild(event);
- }
+ NodeList sessionList = root.getElementsByTagName(SESSION);
+ for (int i = 0; i < sessionList.getLength(); i++){
+ Element session = (Element) sessionList.item(i);
+ String sessionName = session.getAttribute(NAME);
+ if(CURRENT.equals(sessionName))
+ {
+ NodeList eventList = session.getElementsByTagName(EVENT);
+ for (int j = 0; j < eventList.getLength(); j++){
+ Element event = (Element) eventList.item(j);
+ String eventName = event.getAttribute(NAME);
+ session.removeChild(event);
+ File file = new File (SessionManager.OPXML_PREFIX + SessionManager.MODEL_DATA + eventName + SessionManager.CURRENT);
+ file.delete();
+ if (sessionList.getLength() == 0){
+ root.removeChild(session);
}
}
}
+ }
}
-
+
/**
* Remove a session named sessionName that is under eventName if it exists.
* @param sessionName
* @param eventName
*/
public void removeSession(String sessionName, String eventName) {
- Element event = find(root, EVENT, NAME, eventName);
- if (event != null){
- removeSessionHelper(sessionName, event);
+ NodeList list = root.getElementsByTagName(SESSION);
+ for (int i = 0; i < list.getLength(); i++) {
+
+ if (list.item(i) instanceof Element) {
+ Element session = (Element) list.item(i);
+ if (session.getAttribute(NAME).equals(sessionName)) {
+ Element event = find((Element) list.item(0), EVENT, NAME,
+ eventName);
+ if (event != null) {
+ removeSessionHelper(sessionName, event);
+ }
+ }
+ }
}
}
-
- private void removeSessionHelper(String sessionName, Element elem){
- NodeList list = elem.getElementsByTagName(SESSION);
- for (int i = 0; i < list.getLength(); i++){
- if (list.item(i) instanceof Element){
+
+ /**
+ * remove event elem for given session sessionName , also remove session if there
+ * is no event under it.
+ * @param sessionName
+ * @param elem
+ *
+ */
+ private void removeSessionHelper(String sessionName, Element elem) {
+ NodeList list = root.getElementsByTagName(SESSION);
+ for (int i = 0; i < list.getLength(); i++) {
+ if (list.item(i) instanceof Element) {
Element e = (Element) list.item(i);
- if (e.getAttribute(NAME).equals(sessionName)){
- elem.removeChild(e);
- if (list.getLength() == 0){
- root.removeChild(elem);
+ if (e.getAttribute(NAME).equals(sessionName)) {
+ NodeList events = e.getElementsByTagName(EVENT);
+ for (int j = 0; j < events.getLength(); j++) {
+ Element event = (Element) events.item(j);
+ if (event.getAttribute(NAME).equals(
+ elem.getAttribute(NAME))) {
+ e.removeChild(event);
+ }
+ if (events.getLength() == 0) {
+ root.removeChild(e);
+ }
}
}
}
}
}
-
+
/**
* Return a list of the events run with the given session
* @param sessionName the name of the session
@@ -197,18 +225,19 @@ public class SessionManager {
* given session.
*/
public ArrayList<String> getSessionEvents(String sessionName){
- ArrayList<String> ret = new ArrayList<>();
- NodeList eventList = root.getElementsByTagName(EVENT);
-
+ ArrayList<String> ret = new ArrayList<String>();
+ NodeList eventList = root.getElementsByTagName(SESSION);
+
for (int i = 0; i < eventList.getLength(); i++){
if (eventList.item(i) instanceof Element){
Element event = ((Element)eventList.item(i));
- NodeList sessionList = event.getElementsByTagName(SESSION);
- for (int j = 0; j < sessionList.getLength(); j++){
- if (sessionList.item(j) instanceof Element){
- Element session = ((Element)sessionList.item(j));
- if (session.getAttribute(NAME).equals(sessionName)){
- ret.add(event.getAttribute(NAME));
+ if (event.getAttribute(NAME).equals(sessionName)){
+
+ NodeList sessionList = event.getElementsByTagName(EVENT);
+ for (int j = 0; j < sessionList.getLength(); j++){
+ if (sessionList.item(j) instanceof Element){
+ Element session = ((Element)sessionList.item(j));
+ ret.add(session.getAttribute(NAME));
}
}
}
@@ -216,14 +245,14 @@ public class SessionManager {
}
return ret;
}
-
+
/**
* Write back to the same file, that the data was loaded from.
*/
public void write (){
writeToFile(absfilePath);
}
-
+
/**
* Write the contents of the given Document to a file.
*/
@@ -241,6 +270,4 @@ public class SessionManager {
e.printStackTrace();
}
}
-
-
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java
index 7436249..66583a1 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java
@@ -25,12 +25,12 @@ import org.xml.sax.Attributes;
public class SessionsProcessor extends XMLProcessor {
public static class SessionInfo {
/**
- * A list of SessionEvents
+ * A list of Session as well as Events under each of them
*/
- public ArrayList<OpModelEvent> list;
-
- public SessionInfo(ArrayList<OpModelEvent> list){
- this.list = list;
+ public ArrayList<OpModelSession> list;
+
+ public SessionInfo(ArrayList<OpModelSession> session){
+ this.list = session;
}
}
@@ -54,8 +54,8 @@ public class SessionsProcessor extends XMLProcessor {
/**
* A list of all sessions
*/
- private ArrayList<OpModelSession> sessionList;
-
+ private ArrayList<OpModelEvent> eventList;
+
/**
* @see org.eclipse.linuxtools.internal.oprofile.core.opxml.XMLProcessor#startElement(java.lang.String, org.xml.sax.Attributes, java.lang.Object)
*/
@@ -63,11 +63,11 @@ public class SessionsProcessor extends XMLProcessor {
public void startElement(String name, Attributes attrs, Object callData) {
if (name.equals(SESSION_TAG)) {
String sessionName = valid_string(attrs.getValue(SESSION_NAME_ATTR));
- currentSession = new OpModelSession(currentEvent, sessionName);
+ currentSession = new OpModelSession(sessionName);
+ eventList = new ArrayList<OpModelEvent>();
} else if (name.equals(EVENT_TAG)) {
String eventName = attrs.getValue(EVENT_NAME_ATTR);
- currentEvent = new OpModelEvent(eventName);
- sessionList = new ArrayList<>();
+ currentEvent = new OpModelEvent(currentSession,eventName);
} else {
super.startElement(name, attrs, callData);
}
@@ -80,18 +80,18 @@ public class SessionsProcessor extends XMLProcessor {
public void endElement(String name, Object callData) {
if (name.equals(SESSION_TAG)) {
// Got end of session -- save in session list
- sessionList.add(currentSession);
+ OpModelEvent[] s = new OpModelEvent[eventList.size()];
+ eventList.toArray(s);
+ currentSession.setEvents(s);
+ SessionInfo info = (SessionInfo) callData;
+ info.list.add(currentSession);
currentSession = null;
+ eventList = null;
} else if (name.equals(EVENT_TAG)) {
// Got end of event -- save session list into current OpModelEvent and
// save current event into call data
- OpModelSession[] s = new OpModelSession[sessionList.size()];
- sessionList.toArray(s);
- currentEvent.setSessions(s);
- SessionInfo info = (SessionInfo) callData;
- info.list.add(currentEvent);
+ eventList.add(currentEvent);
currentEvent = null;
- sessionList = null;
} else {
super.endElement(name, callData);
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java
index d282142..00c5cfd 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java
@@ -12,6 +12,8 @@ package org.eclipse.linuxtools.internal.oprofile.launch.configuration;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.core.resources.IProject;
@@ -20,6 +22,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -29,6 +33,8 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.window.IShellProvider;
import org.eclipse.linuxtools.internal.oprofile.core.Oprofile.OprofileProject;
import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent;
@@ -48,7 +54,11 @@ 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.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
@@ -80,12 +90,17 @@ AbstractLaunchConfigurationTab {
//tabs for each of the counters
counters = getOprofileCounters(null);
TabItem[] counterTabs = new TabItem[counters.length];
- counterSubTabs = new CounterSubTab[counters.length];
+
+ // create only one counter for operf/opcontrol
+ counterSubTabs = new CounterSubTab[1];
TabFolder tabFolder = new TabFolder(top, SWT.NONE);
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ // As per Roland suggestion if we decide to list all the selected events
+ // in a separate list viewer, then it makes sense to always show just one tab.
+ // This approach would make operf/opcontrol event selection more similar.
for (int i = 0; i < counters.length; i++) {
Composite c = new Composite(tabFolder, SWT.NONE);
CounterSubTab currentTab = new CounterSubTab(c, counters[i]);
@@ -93,7 +108,9 @@ AbstractLaunchConfigurationTab {
counterTabs[i] = new TabItem(tabFolder, SWT.NONE);
counterTabs[i].setControl(c);
- counterTabs[i].setText(OprofileLaunchMessages.getString("tab.event.counterTab.counterText") + String.valueOf(i)); //$NON-NLS-1$
+ counterTabs[i].setText(OprofileLaunchMessages.getString("tab.event.counterTab.counterText")); //$NON-NLS-1$
+ // just one tab for operf/opcontrol
+ break;
}
getTabFolderComposite();
@@ -227,6 +244,20 @@ AbstractLaunchConfigurationTab {
if(counterSubTab.enabledCheck.getSelection() && config.getAttribute(OprofileLaunchPlugin.ATTR_NUMBER_OF_EVENTS(nr), 0) == 0){
valid = false;
}
+ // if target list is empty valid is false
+ // target event list item count
+ int count = counterSubTab.selectedEventList.getList().getItemCount();
+ if(count == 0)
+ {
+ valid = false;
+ }
+ // number of event is allowed in opcontrol binary is equal to number of h/w counter
+ if(OprofileProject.OPCONTROL_BINARY.equals(OprofileProject.getProfilingBinary()) && count > counters.length)
+ {
+ Object[] args = new Object[] { counters.length };
+ setErrorMessage(MessageFormat.format(OprofileLaunchMessages.getString("tab.event.opcontrol.validation.msg"),args));
+ valid = false;
+ }
}
if (counters[i].getEnabled()) {
@@ -241,6 +272,11 @@ AbstractLaunchConfigurationTab {
// First check min count
int min = event.getMinCount();
if (counters[i].getCount() < min) {
+ Object[] args = new Object[] { min };
+ setErrorMessage(MessageFormat
+ .format(OprofileLaunchMessages
+ .getString("tab.event.counterSettings.count.too-small"),
+ args));
valid = false;
break;
}
@@ -248,6 +284,8 @@ AbstractLaunchConfigurationTab {
// Next ask oprofile if it is valid
if (!checkEventSetupValidity(
counters[i].getNumber(), event.getText(), event.getUnitMask().getMaskValue())) {
+ Object[] args = new Object[] { event.getText() };
+ setErrorMessage(MessageFormat.format(OprofileLaunchMessages.getString("tab.event.validation.msg"), args));
valid = false;
break;
}
@@ -418,6 +456,22 @@ AbstractLaunchConfigurationTab {
protected Button enabledCheck;
protected ListViewer eventList;
+ protected Button add;
+ protected Button addAll;
+ protected Button remove;
+ protected Button removeAll;
+ protected Button customizeBtn;
+ protected ListViewer selectedEventList;
+ protected ScrolledComposite unitmaskScrollComposite;
+ protected Composite unitMaskSubComposite ;
+ private final int ADD = 1;
+ private final int ADD_ALL = 2;
+ private final int REMOVE = 3;
+ private final int REMOVE_ALL = 4;
+ private final int CUSTOMIZE = 5;
+ private List<OpEvent> sourceList = new ArrayList<OpEvent>(0);
+ private List<OpEvent> targetList = new ArrayList<OpEvent>(0);
+
public Composite getTabTopContainer() {
return tabTopContainer;
@@ -475,31 +529,17 @@ AbstractLaunchConfigurationTab {
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
+ layout.numColumns = 3;
eventListComp.setLayout(layout);
+ eventListComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
//layoutdata is set later
createLeftCell(eventListComp);
- //right side composite group for other event config and unit mask
- Composite eventConfigComp = new Composite(tabTopContainer, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- eventConfigComp.setLayout(layout);
- eventConfigComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- createRightCell(eventConfigComp);
-
-
- //set the list's composite layout based on the right cell's size
- GridData data = new GridData(SWT.FILL, SWT.FILL, false, true);
- data.heightHint = eventConfigComp.getSize().x;
- eventListComp.setLayoutData(data);
-
scrolledTop = scrolledContainer;
this.tabTopContainer = tabTopContainer;
+ resizeScrollContainer();
}
/**
@@ -550,6 +590,9 @@ AbstractLaunchConfigurationTab {
}
});
+ // profile user binary and profile kernel
+ createRightCell(parent);
+
int options = SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER;
if (OprofileProject.getProfilingBinary().equals(OprofileProject.OPERF_BINARY)) {
options |= SWT.MULTI;
@@ -557,7 +600,9 @@ AbstractLaunchConfigurationTab {
options |= SWT.SINGLE;
}
eventList = new ListViewer(parent, options);
- eventList.getList().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
+ GridData gdata = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gdata.verticalSpan = 5;
+ eventList.getList().setLayoutData(gdata);
eventList.setLabelProvider(new ILabelProvider(){
@Override
@@ -580,8 +625,8 @@ AbstractLaunchConfigurationTab {
eventList.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- OprofileCounter ctr = (OprofileCounter) inputElement;
- return ctr.getValidEvents();
+ List<OpEvent> list = (List<OpEvent>)inputElement;
+ return list.toArray();
}
@Override
public void dispose() { }
@@ -589,8 +634,13 @@ AbstractLaunchConfigurationTab {
public void inputChanged(Viewer arg0, Object arg1, Object arg2) { }
});
+ // sorter
+ ListviewerSorter sorter = new ListviewerSorter();
+ eventList.setSorter(sorter);
+
//adds the events to the list from the counter
- eventList.setInput(counter);
+ sourceList.addAll(Arrays.asList(counter.getValidEvents()));
+ eventList.setInput(sourceList);
eventList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
@@ -598,6 +648,99 @@ AbstractLaunchConfigurationTab {
handleEventListSelectionChange();
}
});
+
+ HandleButtonClick listener = new HandleButtonClick();
+ add = new Button(parent, SWT.PUSH);
+ add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ add.setText(OprofileLaunchMessages.getString("tab.event.addevent.button.text"));
+ add.setData(ADD);
+ add.addListener(SWT.Selection, listener);
+
+ selectedEventList = new ListViewer(parent, options);
+ selectedEventList.getList().setLayoutData(gdata);
+
+
+ selectedEventList.setLabelProvider(new ILabelProvider(){
+ @Override
+ public String getText(Object element) {
+ OpEvent e = (OpEvent) element;
+ return e.getText();
+ }
+ @Override
+ public Image getImage(Object element) { return null; }
+ @Override
+ public void addListener(ILabelProviderListener listener) { }
+ @Override
+ public void dispose() { }
+ @Override
+ public boolean isLabelProperty(Object element, String property) { return false; }
+ @Override
+ public void removeListener(ILabelProviderListener listener) { }
+ });
+
+ selectedEventList.setContentProvider(new IStructuredContentProvider() {
+ @Override
+ public Object[] getElements(Object inputElement) {
+ List<OpEvent> list = (List<OpEvent>)inputElement;
+ return list.toArray();
+ }
+ @Override
+ public void dispose() { }
+ @Override
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) { }
+ });
+
+ // sorter
+ sorter = new ListviewerSorter();
+ selectedEventList.setSorter(sorter);
+
+ //adds the events to the list from the counter
+ if(counter.getEvents().length != 0 && null != counter.getEvents()[0])
+ {
+ targetList.addAll(Arrays.asList(counter.getEvents()));
+ }
+ selectedEventList.setInput(targetList);
+
+ selectedEventList.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent sce) {
+ handleListSelection(selectedEventList);
+ eventList.getList().deselectAll();
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+
+
+
+
+ addAll = new Button(parent, SWT.PUSH);
+ addAll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ addAll.setText(OprofileLaunchMessages.getString("tab.event.addallevent.button.text"));
+ addAll.setData(ADD_ALL);
+ addAll.addListener(SWT.Selection, listener);
+
+
+ remove = new Button(parent, SWT.PUSH);
+ remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ remove.setText(OprofileLaunchMessages.getString("tab.event.removeevent.button.text"));
+ remove.setData(REMOVE);
+ remove.addListener(SWT.Selection, listener);
+
+
+ removeAll = new Button(parent, SWT.PUSH);
+ removeAll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ removeAll.setText(OprofileLaunchMessages.getString("tab.event.removeallevent.button.text"));
+ removeAll.setData(REMOVE_ALL);
+ removeAll.addListener(SWT.Selection, listener);
+
+ customizeBtn = new Button(parent, SWT.PUSH);
+ customizeBtn.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ customizeBtn.setText(OprofileLaunchMessages.getString("tab.event.customizeevent.button.text"));
+ customizeBtn.addListener(SWT.Selection, listener);
+ customizeBtn.setData(CUSTOMIZE);
+
+
}
/**
@@ -625,27 +768,6 @@ AbstractLaunchConfigurationTab {
}
});
- //event count label/text
- countTextLabel = new Label(parent, SWT.NONE);
- countTextLabel.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.count.label.text")); //$NON-NLS-1$
- countText = new Text(parent, SWT.SINGLE | SWT.BORDER);
- countText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- countText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent me) {
- handleCountTextModify();
- }
- });
-
- //unit mask widget
- Composite unitMaskComp = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- unitMaskComp.setLayout(layout);
- unitMaskComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
-
- unitMaskViewer = new UnitMaskViewer(unitMaskComp);
}
/**
@@ -712,10 +834,22 @@ AbstractLaunchConfigurationTab {
//load default states
profileKernelCheck.setSelection(counter.getProfileKernel());
profileUserCheck.setSelection(counter.getProfileUser());
- countText.setText(Integer.toString(counter.getCount()));
+
eventDescText.setText(counter.getEvents()[0].getTextDescription());
- unitMaskViewer.displayEvent(counter.getEvents()[0]);
- eventList.setSelection(new StructuredSelection(counter.getEvents()));
+
+
+ // add opevent to target event list
+ ArrayList<OpEvent> tmp = new ArrayList<OpEvent>(Arrays.asList(counter.getEvents()));
+ targetList.addAll(tmp);
+ selectedEventList.add(tmp.toArray());
+ selectedEventList.refresh();
+ selectedEventList.setSelection(new StructuredSelection(tmp.toArray()));
+
+ // remove selected opevent from source list
+
+ sourceList.removeAll(tmp);
+ eventList.remove(tmp.toArray());
+ eventList.refresh();
}
/**
@@ -748,11 +882,17 @@ AbstractLaunchConfigurationTab {
private void internalSetEnabledState(boolean state) {
profileKernelCheck.setEnabled(state);
profileUserCheck.setEnabled(state);
- countText.setEnabled(state);
eventDescText.setEnabled(state);
- unitMaskViewer.setEnabled(state);
eventList.getList().setEnabled(state);
+ selectedEventList.getList().setEnabled(state);
eventFilterText.setEnabled(state);
+ add.setEnabled(state);
+ addAll.setEnabled(state);
+ remove.setEnabled(state);
+ removeAll.setEnabled(state);
+ customizeBtn.setEnabled(state);
+
+
}
/**
@@ -760,14 +900,35 @@ AbstractLaunchConfigurationTab {
* and updates the UnitMask and event description text box.
*/
private void handleEventListSelectionChange() {
+ handleListSelection(eventList);
+ int[] indices = eventList.getList().getSelectionIndices();
+ if (indices.length != 0) {
+ customizeBtn.setEnabled(true);
+ // unselected other list element
+ // to keep customize button enable
+ // for both list selection
+ selectedEventList.getList().deselectAll();
+ }
+ updateLaunchConfigurationDialog();
+
+ }
+
+ /**
+ * Generic method for handling source & target selection list
+ * @param eventList - list to be handled
+ * @since 3.0
+ */
+ private void handleListSelection(ListViewer eventList)
+ {
+ setErrorMessage(null);
int [] indices = eventList.getList().getSelectionIndices();
if (indices.length != 0) {
- ArrayList<OpEvent> tmp = new ArrayList<> ();
+ ArrayList<OpEvent> tmp = new ArrayList<OpEvent> ();
for (int index : indices) {
OpEvent event = (OpEvent) eventList.getElementAt(index);
tmp.add(event);
eventDescText.setText(event.getTextDescription());
- unitMaskViewer.displayEvent(event);
+
}
// Check the min count to update the error message (events
@@ -780,20 +941,23 @@ AbstractLaunchConfigurationTab {
min = ev.getMinCount();
}
}
+ if(counter.getEvents().length == 0 || counter.getEvents()[0] == null)
+ {
+ counter.setEvents(new OpEvent [] {counter.getValidEvents()[0]});
+ }
if ((counter.getCount() < min)
&& (!defaultEventCheck.getSelection())) {
setErrorMessage(getMinCountErrorMessage(min));
}
- counter.setEvents(tmp.toArray(new OpEvent[0]));
+ //counter.setEvents(tmp.toArray(new OpEvent[0]));
} else {
eventDescText.setText(""); //$NON-NLS-1$
- if(unitMaskViewer != null){
- unitMaskViewer.displayEvent(null);
- }
+
}
- updateLaunchConfigurationDialog();
+
+
}
/**
@@ -945,7 +1109,7 @@ AbstractLaunchConfigurationTab {
//creates these buttons with the default masks
mask.setDefaultMaskValue();
- ArrayList<Button> maskButtons = new ArrayList<>();
+ ArrayList<Button> maskButtons = new ArrayList<Button>();
for (int i = 0; i < totalMasks; i++) {
Button maskButton;
@@ -988,7 +1152,8 @@ AbstractLaunchConfigurationTab {
unitMaskButtons = new Button[maskButtons.size()];
maskButtons.toArray(unitMaskButtons);
- resizeScrollContainer();
+
+ resizeUnitMaskContainer();
}
/**
@@ -1005,5 +1170,293 @@ AbstractLaunchConfigurationTab {
}
}
}
+
+ /**
+ * Dialog box for unit mask field modification
+ * @since 3.0
+ *
+ */
+ protected class UnitMaskDialog extends Dialog {
+ private OpEvent event;
+ public UnitMaskDialog(IShellProvider parentShell) {
+ super(parentShell);
+ }
+
+ public UnitMaskDialog(Shell parentShell,OpEvent event) {
+ super(parentShell);
+ this.event = event;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite child = (Composite)super.createDialogArea(parent);
+ ScrolledComposite scrolledContainer = new ScrolledComposite(child, SWT.H_SCROLL|SWT.V_SCROLL);
+ scrolledContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ scrolledContainer.setLayout(layout);
+ scrolledContainer.setExpandHorizontal(true);
+ scrolledContainer.setExpandVertical(true);
+ Composite unitMaskSubComposite = new Composite(scrolledContainer, SWT.None);
+ unitMaskSubComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ layout = new GridLayout();
+ layout.numColumns=2;
+ unitMaskSubComposite.setLayout(layout);
+ createUnitMaskComponents(unitMaskSubComposite);
+ scrolledContainer.setContent(unitMaskSubComposite);
+ CounterSubTab.this.unitmaskScrollComposite = scrolledContainer;
+ CounterSubTab.this.unitMaskSubComposite = unitMaskSubComposite;
+ unitMaskViewer.displayEvent(event);
+ return child;
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(event.getText());
+ newShell.setSize(400, 400);
+ }
+ }
+
+
+ private void createUnitMaskComponents(Composite parent)
+ {
+ //event count label/text
+ countTextLabel = new Label(parent, SWT.NONE);
+ countTextLabel.setText(OprofileLaunchMessages.getString("tab.event.counterSettings.count.label.text")); //$NON-NLS-1$
+ countText = new Text(parent, SWT.SINGLE | SWT.BORDER);
+ countText.setText(Integer.toString(counter.getCount()));
+ countText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ countText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent me) {
+ handleCountTextModify();
+ }
+ });
+
+ //unit mask widget
+ Composite unitMaskComp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ unitMaskComp.setLayout(layout);
+ unitMaskComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+
+ unitMaskViewer = new UnitMaskViewer(unitMaskComp);
+ }
+ private void resizeUnitMaskContainer() {
+ unitmaskScrollComposite.setMinSize(unitMaskSubComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ }
+
+ /**
+ * Events selection/removal button listener
+ * @since 3.0
+ *
+ */
+ protected class HandleButtonClick implements Listener
+ {
+
+ @Override
+ public void handleEvent(Event event) {
+ int btn_value = (Integer) event.widget.getData();
+ switch (btn_value) {
+ case ADD:
+ addButtonClicked();
+ updateLaunchConfigurationDialog();
+ break;
+ case ADD_ALL:
+ addAllButtonClicked();
+ updateLaunchConfigurationDialog();
+ break;
+ case REMOVE:
+ removeButtonClicked();
+ updateLaunchConfigurationDialog();
+ break;
+ case REMOVE_ALL:
+ removeAllButtonClicked();
+ updateLaunchConfigurationDialog();
+ break;
+ case CUSTOMIZE:
+ customizeButtonClicked();
+ break;
+ default:
+ System.out.println("unknown option");
+ break;
+ }
+
+ }
+
+ private void addButtonClicked() {
+ int[] indices = eventList.getList().getSelectionIndices();
+ if (indices.length != 0) {
+ ArrayList<OpEvent> tmp = new ArrayList<OpEvent>();
+ for (int index : indices) {
+ OpEvent event = (OpEvent) eventList.getElementAt(index);
+ tmp.add(event);
+ }
+ // add to target list
+ targetList.addAll(tmp);
+ selectedEventList.add(tmp.toArray());
+
+ sourceList.removeAll(tmp);
+ eventList.remove(tmp.toArray());
+
+ int count = selectedEventList.getList().getItemCount();
+ tmp = new ArrayList<OpEvent>();
+ for (int i = 0; i < count; i++) {
+ OpEvent event = (OpEvent) selectedEventList
+ .getElementAt(i);
+ tmp.add(event);
+
+ }
+ if (!tmp.isEmpty())
+ counter.setEvents(tmp.toArray(new OpEvent[0]));
+
+ eventList.refresh();
+ selectedEventList.refresh();
+
+
+ }
+ }
+
+ private void addAllButtonClicked() {
+ int count = eventList.getList().getItemCount();
+ ArrayList<OpEvent> tmp = new ArrayList<OpEvent>();
+ for (int i = 0; i < count; i++) {
+ OpEvent event = (OpEvent) eventList.getElementAt(i);
+ tmp.add(event);
+
+ }
+
+ targetList.addAll(tmp);
+ selectedEventList.add(tmp.toArray());
+ eventList.remove(tmp.toArray());
+ sourceList.removeAll(tmp);
+
+ count = selectedEventList.getList().getItemCount();
+ tmp = new ArrayList<OpEvent>();
+ for (int i = 0; i < count; i++) {
+ OpEvent event = (OpEvent) selectedEventList.getElementAt(i);
+ tmp.add(event);
+
+ }
+ if (!tmp.isEmpty())
+ counter.setEvents(tmp.toArray(new OpEvent[0]));
+
+ eventList.refresh();
+ selectedEventList.refresh();
+
+
+ }
+
+ private void removeButtonClicked() {
+ int[] indices = selectedEventList.getList()
+ .getSelectionIndices();
+ if (indices.length != 0) {
+ ArrayList<OpEvent> tmp = new ArrayList<OpEvent>();
+ for (int index : indices) {
+ OpEvent event = (OpEvent) selectedEventList
+ .getElementAt(index);
+ tmp.add(event);
+ }
+ // add to target list
+ sourceList.addAll(tmp);
+ eventList.add(tmp.toArray());
+
+ targetList.removeAll(tmp);
+ selectedEventList.remove(tmp.toArray());
+
+ int count = selectedEventList.getList().getItemCount();
+ tmp = new ArrayList<OpEvent>();
+ for (int i = 0; i < count; i++) {
+ OpEvent event = (OpEvent) selectedEventList
+ .getElementAt(i);
+ tmp.add(event);
+
+ }
+ if (!tmp.isEmpty())
+ counter.setEvents(tmp.toArray(new OpEvent[0]));
+ else
+ // add first valid element to counter due to NPE
+ counter.setEvents(new OpEvent[]{counter.getValidEvents()[0]});
+
+ eventList.refresh();
+ selectedEventList.refresh();
+
+ }
+ }
+
+ private void removeAllButtonClicked() {
+
+ int count = selectedEventList.getList().getItemCount();
+ ArrayList<OpEvent> tmp = new ArrayList<OpEvent>();
+ for (int i = 0; i < count; i++) {
+ OpEvent event = (OpEvent) selectedEventList.getElementAt(i);
+ tmp.add(event);
+
+ }
+
+ if (!tmp.isEmpty()) {
+ sourceList.addAll(tmp);
+ eventList.add(tmp.toArray());
+
+ selectedEventList.remove(tmp.toArray());
+ targetList.removeAll(tmp);
+
+ }
+ counter.setEvents(new OpEvent[] { counter.getValidEvents()[0] });
+
+ eventList.refresh();
+ selectedEventList.refresh();
+
+ }
+
+ private void customizeButtonClicked() {
+ UnitMaskDialog d = null;
+
+ if(eventList.getList().getSelectionIndex() != -1)
+ {
+ d = new UnitMaskDialog(Display.getCurrent()
+ .getActiveShell(),
+ (OpEvent) eventList.getElementAt(eventList.getList()
+ .getSelectionIndex()));
+ }
+ else if(selectedEventList.getList().getSelectionIndex() != -1)
+ {
+ d = new UnitMaskDialog(Display.getCurrent()
+ .getActiveShell(),
+ (OpEvent) selectedEventList.getElementAt(selectedEventList.getList()
+ .getSelectionIndex()));
+ }
+ if(d != null)
+ d.open();
+ }
+
+ }
+ }
+
+ /**
+ *
+ * Event sorting for selected as well as all available events
+ * @since 3.0
+ */
+ protected class ListviewerSorter extends ViewerSorter
+ {
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ OpEvent op1 = (OpEvent) e1;
+ OpEvent op2 = (OpEvent) e2;
+ String op1txt = op1.getText();
+ String op2txt = op2.getText();
+ if(op1txt !=null && op2txt !=null && op1txt.trim().length() !=0 && op2txt.trim().length() !=0)
+ return collator.compare(op1txt, op2txt);
+ return super.compare(viewer, e1, e2);
+ }
}
} \ No newline at end of file
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties
index a84ece9..da6b41f 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties
@@ -7,8 +7,8 @@
#
# Contributors:
# Keith Seitz <keiths@redhat.com> - initial implementation
-# Kent Sebastian <ksebasti@redhat.com> -
-######################################################################
+# Kent Sebastian <ksebasti@redhat.com> -
+######################################################################
tab.claunch.name=&Application
tab.claunch.launchConfig.label.text=C/C++ Launch &Configuration:
tab.claunch.launchConfig.button.browse.text=&Browse...
@@ -26,9 +26,16 @@ tab.event.counterSettings.count.label.text=Count:
tab.event.counterSettings.count.too-small=Minimum count must be at least {0,number,integer}
tab.event.counterSettings.count.invalid=Invalid count value, must be an integer
tab.event.defaultevent.button.text=Use default event
-tab.event.counterTab.counterText=Ctr
+tab.event.counterTab.counterText=Counter
tab.event.eventfilter.message=type filter text
tab.event.timermode.no.options=OProfile is running in timer mode; no event options can be specified.
+tab.event.addevent.button.text=Add >
+tab.event.addallevent.button.text=Add All >
+tab.event.removeevent.button.text= < Remove
+tab.event.removeallevent.button.text= < Remove All
+tab.event.customizeevent.button.text = Customize Event
+tab.event.validation.msg= Event {0} validation failed
+tab.event.opcontrol.validation.msg= Events count must be equal or less then number of counter [hardware counter is {0}]
tab.global.name=Global
tab.global.select=Profile with:
@@ -37,7 +44,7 @@ tab.global.kernelImage.kernel.nonexistent=Kernel image \"{0}\" does not exist
tab.global.kernelImage.browse.button.text=&Browse...
tab.global.selectKernelDialog.text=Select current kernel file
tab.global.selectKernelDialog.error.kernelDoesNotExist.text=The selected kernel image file does not exist.
-tab.global.check.separateLibrary.text=Include dependent shared libraries
+tab.global.check.separateLibrary.text=Include dependent shared libraries
tab.global.check.separateKernel.text=Include dependent kernel modules (also includes libraries)
tab.global.check.separateThread.text=Separate profiles per thread
tab.global.check.separateCpu.text=Separate profiles per CPU
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession.java b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent.java
index 3c0247d..b738619 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent.java
@@ -7,7 +7,7 @@
*
* Contributors:
* Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.linuxtools.oprofile.tests;
import java.io.FileNotFoundException;
@@ -31,13 +31,13 @@ import org.xml.sax.XMLReader;
/*
* A faked OpModelSession object of a typical image + some dependent images.
*/
-public class TestingOpModelSession extends OpModelSession {
+public class TestingOpModelEvent extends OpModelEvent {
private static final String REL_PATH_TO_TEST_XML = "resources/test_model-data.xml"; //$NON-NLS-1$
public static final String IMAGE_OUTPUT = "/test/path/for/image, Count: 205000, Dependent Count: 5000\nSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\tSample: Line #: 42, Count: 130000\n\tSample: Line #: 36, Count: 40000\n\tSample: Line #: 31, Count: 9999\n\tSample: Line #: 39, Count: 1\nSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\tSample: Line #: 94, Count: 19998\n\tSample: Line #: 12, Count: 1\n\tSample: Line #: 55, Count: 1\nDependent Image: /no-vmlinux, Count: 4400\nDependent Image: /lib64/ld-2.9.so, Count: 300\n\tSymbols: do_lookup_x, File: dl-lookup.c, Count: 299\n\t\tSample: Line #: 0, Count: 299\n\tSymbols: _dl_unload_cache, File: rawmemchr.c, Count: 1\n\t\tSample: Line #: 0, Count: 1\nDependent Image: /usr/lib64/libstdc++.so.6.0.10, Count: 160\nDependent Image: /lib64/libc-2.9.so, Count: 140\n\tSymbols: _IO_new_file_seekoff, File: , Count: 100\n\t\tSample: Line #: 0, Count: 100\n\tSymbols: bcopy, File: , Count: 40\n\t\tSample: Line #: 0, Count: 40\n"; //$NON-NLS-1$
public static final String IMAGE_OUTPUT_WITHTAB = "/test/path/for/image, Count: 205000, Dependent Count: 5000\n\tSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\t\tSample: Line #: 42, Count: 130000\n\t\tSample: Line #: 36, Count: 40000\n\t\tSample: Line #: 31, Count: 9999\n\t\tSample: Line #: 39, Count: 1\n\tSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\t\tSample: Line #: 94, Count: 19998\n\t\tSample: Line #: 12, Count: 1\n\t\tSample: Line #: 55, Count: 1\n\tDependent Image: /no-vmlinux, Count: 4400\n\tDependent Image: /lib64/ld-2.9.so, Count: 300\n\t\tSymbols: do_lookup_x, File: dl-lookup.c, Count: 299\n\t\t\tSample: Line #: 0, Count: 299\n\t\tSymbols: _dl_unload_cache, File: rawmemchr.c, Count: 1\n\t\t\tSample: Line #: 0, Count: 1\n\tDependent Image: /usr/lib64/libstdc++.so.6.0.10, Count: 160\n\tDependent Image: /lib64/libc-2.9.so, Count: 140\n\t\tSymbols: _IO_new_file_seekoff, File: , Count: 100\n\t\t\tSample: Line #: 0, Count: 100\n\t\tSymbols: bcopy, File: , Count: 40\n\t\t\tSample: Line #: 0, Count: 40\n"; //$NON-NLS-1$
- public TestingOpModelSession(OpModelEvent event, String name) {
- super(event, name);
+ public TestingOpModelEvent(OpModelSession session, String name) {
+ super(session, name);
}
@Override
protected OpModelImage getNewImage() {
@@ -48,15 +48,15 @@ public class TestingOpModelSession extends OpModelSession {
parsedImage = new OpModelImage();
ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
-
+
// Create XMLReader
SAXParserFactory factory = SAXParserFactory.newInstance();
reader = factory.newSAXParser().getXMLReader();
-
+
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
-
+
String filePath = FileLocator.toFileURL(FileLocator.find(TestPlugin.getDefault().getBundle(), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
} catch (FileNotFoundException e) {
@@ -68,7 +68,7 @@ public class TestingOpModelSession extends OpModelSession {
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
-
+
return parsedImage;
}
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession2.java b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent2.java
index 4fe1559..803a58c 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession2.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent2.java
@@ -7,7 +7,7 @@
*
* Contributors:
* Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.linuxtools.oprofile.tests;
import java.io.FileNotFoundException;
@@ -31,13 +31,13 @@ import org.xml.sax.XMLReader;
/*
* A faked OpModelSession object of a typical image with no dependent images.
*/
-public class TestingOpModelSession2 extends OpModelSession {
+public class TestingOpModelEvent2 extends OpModelEvent {
private static final String REL_PATH_TO_TEST_XML = "resources/test_model-data_nodepimage.xml"; //$NON-NLS-1$
public static final String IMAGE_OUTPUT = "/test/path/for/image, Count: 205000, Dependent Count: 5000\nSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\tSample: Line #: 42, Count: 130000\n\tSample: Line #: 36, Count: 40000\n\tSample: Line #: 31, Count: 9999\n\tSample: Line #: 39, Count: 1\nSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\tSample: Line #: 94, Count: 19998\n\tSample: Line #: 12, Count: 1\n\tSample: Line #: 55, Count: 1\n"; //$NON-NLS-1$
public static final String IMAGE_OUTPUT_WITHTAB = "/test/path/for/image, Count: 205000, Dependent Count: 5000\n\tSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\t\tSample: Line #: 42, Count: 130000\n\t\tSample: Line #: 36, Count: 40000\n\t\tSample: Line #: 31, Count: 9999\n\t\tSample: Line #: 39, Count: 1\n\tSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\t\tSample: Line #: 94, Count: 19998\n\t\tSample: Line #: 12, Count: 1\n\t\tSample: Line #: 55, Count: 1\n"; //$NON-NLS-1$
- public TestingOpModelSession2(OpModelEvent event, String name) {
- super(event, name);
+ public TestingOpModelEvent2(OpModelSession session, String name) {
+ super(session, name);
}
@Override
protected OpModelImage getNewImage() {
@@ -48,15 +48,15 @@ public class TestingOpModelSession2 extends OpModelSession {
parsedImage = new OpModelImage();
ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
-
+
// Create XMLReader
SAXParserFactory factory = SAXParserFactory.newInstance();
reader = factory.newSAXParser().getXMLReader();
-
+
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
-
+
String filePath = FileLocator.toFileURL(FileLocator.find(TestPlugin.getDefault().getBundle(), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
} catch (FileNotFoundException e) {
@@ -68,7 +68,7 @@ public class TestingOpModelSession2 extends OpModelSession {
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
-
+
return parsedImage;
}
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession3.java b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent3.java
index afacd70..fb87336 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession3.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent3.java
@@ -7,7 +7,7 @@
*
* Contributors:
* Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.linuxtools.oprofile.tests;
import java.io.FileNotFoundException;
@@ -32,11 +32,11 @@ import org.xml.sax.XMLReader;
* A faked OpModelSession object when there are multiple images in the session,
* simulating when the session was not created from within the eclipse plugin.
*/
-public class TestingOpModelSession3 extends OpModelSession {
+public class TestingOpModelEvent3 extends OpModelEvent {
private static final String REL_PATH_TO_TEST_XML = "resources/test_model-data_multiple_image.xml"; //$NON-NLS-1$
- public TestingOpModelSession3(OpModelEvent event, String name) {
- super(event, name);
+ public TestingOpModelEvent3(OpModelSession session, String name) {
+ super(session, name);
}
@Override
protected OpModelImage getNewImage() {
@@ -47,15 +47,15 @@ public class TestingOpModelSession3 extends OpModelSession {
parsedImage = new OpModelImage();
ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
-
+
// Create XMLReader
SAXParserFactory factory = SAXParserFactory.newInstance();
reader = factory.newSAXParser().getXMLReader();
-
+
// Set content/error handlers
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
-
+
String filePath = FileLocator.toFileURL(FileLocator.find(TestPlugin.getDefault().getBundle(), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
reader.parse(new InputSource(new FileReader(filePath)));
} catch (FileNotFoundException e) {
@@ -67,7 +67,7 @@ public class TestingOpModelSession3 extends OpModelSession {
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
-
+
return parsedImage;
}
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession4.java b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent4.java
index a40c46b..822d434 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelSession4.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelEvent4.java
@@ -7,7 +7,7 @@
*
* Contributors:
* Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.linuxtools.oprofile.tests;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
@@ -15,13 +15,13 @@ import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
/*
- * A faked OpModelSession object where there is no image.
+ * A faked OpModelSession object where there is no image.
* Note: technically this shouldn't really happen in normal operation
* of the plugin unless there is a major b0rk-up with the xml parsers..
*/
-public class TestingOpModelSession4 extends OpModelSession {
- public TestingOpModelSession4(OpModelEvent event, String name) {
- super(event, name);
+public class TestingOpModelEvent4 extends OpModelEvent {
+ public TestingOpModelEvent4(OpModelSession session, String name) {
+ super(session, name);
}
@Override
protected OpModelImage getNewImage() {
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelRoot.java b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelRoot.java
index 5bf1ee7..80d7550 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelRoot.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.tests/src/org/eclipse/linuxtools/oprofile/tests/TestingOpModelRoot.java
@@ -15,24 +15,28 @@ import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
public class TestingOpModelRoot extends OpModelRoot {
- public static final String ROOT_OUTPUT = "Event: testEvent1\n\tSession: testSession1e1\n\t\tImage: /test/path/for/image, Count: 205000, Dependent Count: 5000\n\t\t\tSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\t\t\t\tSample: Line #: 42, Count: 130000\n\t\t\t\tSample: Line #: 36, Count: 40000\n\t\t\t\tSample: Line #: 31, Count: 9999\n\t\t\t\tSample: Line #: 39, Count: 1\n\t\t\tSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\t\t\t\tSample: Line #: 94, Count: 19998\n\t\t\t\tSample: Line #: 12, Count: 1\n\t\t\t\tSample: Line #: 55, Count: 1\n\t\t\tDependent Image: /no-vmlinux, Count: 4400\n\t\t\tDependent Image: /lib64/ld-2.9.so, Count: 300\n\t\t\t\tSymbols: do_lookup_x, File: dl-lookup.c, Count: 299\n\t\t\t\t\tSample: Line #: 0, Count: 299\n\t\t\t\tSymbols: _dl_unload_cache, File: rawmemchr.c, Count: 1\n\t\t\t\t\tSample: Line #: 0, Count: 1\n\t\t\tDependent Image: /usr/lib64/libstdc++.so.6.0.10, Count: 160\n\t\t\tDependent Image: /lib64/libc-2.9.so, Count: 140\n\t\t\t\tSymbols: _IO_new_file_seekoff, File: , Count: 100\n\t\t\t\t\tSample: Line #: 0, Count: 100\n\t\t\t\tSymbols: bcopy, File: , Count: 40\n\t\t\t\t\tSample: Line #: 0, Count: 40\nEvent: testEvent2\n\tSession: testSession1e2\n\t\tImage: /test/path/for/image, Count: 205000, Dependent Count: 5000\n\t\t\tSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\t\t\t\tSample: Line #: 42, Count: 130000\n\t\t\t\tSample: Line #: 36, Count: 40000\n\t\t\t\tSample: Line #: 31, Count: 9999\n\t\t\t\tSample: Line #: 39, Count: 1\n\t\t\tSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\t\t\t\tSample: Line #: 94, Count: 19998\n\t\t\t\tSample: Line #: 12, Count: 1\n\t\t\t\tSample: Line #: 55, Count: 1\n\t\t\tDependent Image: /no-vmlinux, Count: 4400\n\t\t\tDependent Image: /lib64/ld-2.9.so, Count: 300\n\t\t\t\tSymbols: do_lookup_x, File: dl-lookup.c, Count: 299\n\t\t\t\t\tSample: Line #: 0, Count: 299\n\t\t\t\tSymbols: _dl_unload_cache, File: rawmemchr.c, Count: 1\n\t\t\t\t\tSample: Line #: 0, Count: 1\n\t\t\tDependent Image: /usr/lib64/libstdc++.so.6.0.10, Count: 160\n\t\t\tDependent Image: /lib64/libc-2.9.so, Count: 140\n\t\t\t\tSymbols: _IO_new_file_seekoff, File: , Count: 100\n\t\t\t\t\tSample: Line #: 0, Count: 100\n\t\t\t\tSymbols: bcopy, File: , Count: 40\n\t\t\t\t\tSample: Line #: 0, Count: 40\n\tSession: testSession2e2\n\t\tImage: /test/path/for/image, Count: 200000\n\t\t\tSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\t\t\t\tSample: Line #: 42, Count: 130000\n\t\t\t\tSample: Line #: 36, Count: 40000\n\t\t\t\tSample: Line #: 31, Count: 9999\n\t\t\t\tSample: Line #: 39, Count: 1\n\t\t\tSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\t\t\t\tSample: Line #: 94, Count: 19998\n\t\t\t\tSample: Line #: 12, Count: 1\n\t\t\t\tSample: Line #: 55, Count: 1\n\tSession: testSession3e2\n\t\tImage: , Count: -1\n\tSession: testSession4e2\n"; //$NON-NLS-1$
- public static final String NAME_E1 = "testEvent1"; //$NON-NLS-1$
- public static final String NAME_E2 = "testEvent2"; //$NON-NLS-1$
- public static final String NAME_E1_S1 = "testSession1e1"; //$NON-NLS-1$
- public static final String NAME_E2_S1 = "testSession1e2"; //$NON-NLS-1$
- public static final String NAME_E2_S2 = "testSession2e2"; //$NON-NLS-1$
- public static final String NAME_E2_S3 = "testSession3e2"; //$NON-NLS-1$
- public static final String NAME_E2_S4 = "testSession4e2"; //$NON-NLS-1$
+ public static final String ROOT_OUTPUT = "Session: testSession1\n\tEvent: testEvent1e1\n\t\tImage: /test/path/for/image, Count: 205000, Dependent Count: 5000\n\t\t\tSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\t\t\t\tSample: Line #: 42, Count: 130000\n\t\t\t\tSample: Line #: 36, Count: 40000\n\t\t\t\tSample: Line #: 31, Count: 9999\n\t\t\t\tSample: Line #: 39, Count: 1\n\t\t\tSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\t\t\t\tSample: Line #: 94, Count: 19998\n\t\t\t\tSample: Line #: 12, Count: 1\n\t\t\t\tSample: Line #: 55, Count: 1\n\t\t\tDependent Image: /no-vmlinux, Count: 4400\n\t\t\tDependent Image: /lib64/ld-2.9.so, Count: 300\n\t\t\t\tSymbols: do_lookup_x, File: dl-lookup.c, Count: 299\n\t\t\t\t\tSample: Line #: 0, Count: 299\n\t\t\t\tSymbols: _dl_unload_cache, File: rawmemchr.c, Count: 1\n\t\t\t\t\tSample: Line #: 0, Count: 1\n\t\t\tDependent Image: /usr/lib64/libstdc++.so.6.0.10, Count: 160\n\t\t\tDependent Image: /lib64/libc-2.9.so, Count: 140\n\t\t\t\tSymbols: _IO_new_file_seekoff, File: , Count: 100\n\t\t\t\t\tSample: Line #: 0, Count: 100\n\t\t\t\tSymbols: bcopy, File: , Count: 40\n\t\t\t\t\tSample: Line #: 0, Count: 40\nSession: testSession2\n\tEvent: testEvent1e2\n\t\tImage: /test/path/for/image, Count: 205000, Dependent Count: 5000\n\t\t\tSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\t\t\t\tSample: Line #: 42, Count: 130000\n\t\t\t\tSample: Line #: 36, Count: 40000\n\t\t\t\tSample: Line #: 31, Count: 9999\n\t\t\t\tSample: Line #: 39, Count: 1\n\t\t\tSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\t\t\t\tSample: Line #: 94, Count: 19998\n\t\t\t\tSample: Line #: 12, Count: 1\n\t\t\t\tSample: Line #: 55, Count: 1\n\t\t\tDependent Image: /no-vmlinux, Count: 4400\n\t\t\tDependent Image: /lib64/ld-2.9.so, Count: 300\n\t\t\t\tSymbols: do_lookup_x, File: dl-lookup.c, Count: 299\n\t\t\t\t\tSample: Line #: 0, Count: 299\n\t\t\t\tSymbols: _dl_unload_cache, File: rawmemchr.c, Count: 1\n\t\t\t\t\tSample: Line #: 0, Count: 1\n\t\t\tDependent Image: /usr/lib64/libstdc++.so.6.0.10, Count: 160\n\t\t\tDependent Image: /lib64/libc-2.9.so, Count: 140\n\t\t\t\tSymbols: _IO_new_file_seekoff, File: , Count: 100\n\t\t\t\t\tSample: Line #: 0, Count: 100\n\t\t\t\tSymbols: bcopy, File: , Count: 40\n\t\t\t\t\tSample: Line #: 0, Count: 40\n\tEvent: testEvent2e2\n\t\tImage: /test/path/for/image, Count: 200000\n\t\t\tSymbols: TestFunction1(int), File: /test/path/for/src/image.cpp, Count: 180000\n\t\t\t\tSample: Line #: 42, Count: 130000\n\t\t\t\tSample: Line #: 36, Count: 40000\n\t\t\t\tSample: Line #: 31, Count: 9999\n\t\t\t\tSample: Line #: 39, Count: 1\n\t\t\tSymbols: TestFunction2(int, int), File: /test/path/for/src/image2.cpp, Count: 20000\n\t\t\t\tSample: Line #: 94, Count: 19998\n\t\t\t\tSample: Line #: 12, Count: 1\n\t\t\t\tSample: Line #: 55, Count: 1\n\tEvent: testEvent3e2\n\t\tImage: , Count: -1\n\tEvent: testEvent4e2\n"; //$NON-NLS-1$
+ public static final String NAME_E1 = "testSession1"; //$NON-NLS-1$
+ public static final String NAME_E2 = "testSession2"; //$NON-NLS-1$
+ public static final String NAME_E1_S1 = "testEvent1e1"; //$NON-NLS-1$
+ public static final String NAME_E2_S1 = "testEvent1e2"; //$NON-NLS-1$
+ public static final String NAME_E2_S2 = "testEvent2e2"; //$NON-NLS-1$
+ public static final String NAME_E2_S3 = "testEvent3e2"; //$NON-NLS-1$
+ public static final String NAME_E2_S4 = "testEvent4e2"; //$NON-NLS-1$
@Override
- protected OpModelEvent[] getNewEvents() {
+ protected OpModelSession[] getNewSessions() {
//fake running opxml and simply return hand-made events
- OpModelEvent[] e = {new OpModelEvent(NAME_E1), new OpModelEvent(NAME_E2), null};
- e[0].setSessions(new TestingOpModelSession[] {new TestingOpModelSession(e[0], NAME_E1_S1)});
- e[1].setSessions(new OpModelSession[] {
- new TestingOpModelSession(e[1], NAME_E2_S1),
- new TestingOpModelSession2(e[1], NAME_E2_S2),
- new TestingOpModelSession3(e[1], NAME_E2_S3),
- new TestingOpModelSession4(e[1], NAME_E2_S4)});
+ OpModelSession[] e = {new OpModelSession(NAME_E1), new OpModelSession(NAME_E2), null};
+ e[0].setEvents(new TestingOpModelEvent[] {new TestingOpModelEvent(e[0], NAME_E1_S1)});
+ e[1].setEvents(new OpModelEvent[] {
+ new TestingOpModelEvent(e[1], NAME_E2_S1),
+ new TestingOpModelEvent2(e[1], NAME_E2_S2),
+ new TestingOpModelEvent3(e[1], NAME_E2_S3),
+ new TestingOpModelEvent4(e[1], NAME_E2_S4)});
+
+
+
+
return e;
}
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui.tests/src/org/eclipse/linuxtools/oprofile/ui/tests/TestUiDataModel.java b/oprofile/org.eclipse.linuxtools.oprofile.ui.tests/src/org/eclipse/linuxtools/oprofile/ui/tests/TestUiDataModel.java
index 31631a0..f92ba03 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui.tests/src/org/eclipse/linuxtools/oprofile/ui/tests/TestUiDataModel.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui.tests/src/org/eclipse/linuxtools/oprofile/ui/tests/TestUiDataModel.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
import org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot;
import org.eclipse.linuxtools.oprofile.ui.model.UiModelSample;
@@ -31,16 +32,16 @@ public class TestUiDataModel {
private static class TestingUiModelRoot extends UiModelRoot {
@Override
- protected OpModelEvent[] getModelDataEvents() {
+ protected OpModelSession[] getModelDataEvents() {
TestingOpModelRoot modelRoot = new TestingOpModelRoot();
modelRoot.refreshModel();
- return modelRoot.getEvents();
+ return modelRoot.getSessions();
}
}
private static class TestingUiModelRoot2 extends UiModelRoot {
@Override
- protected OpModelEvent[] getModelDataEvents() {
+ protected OpModelSession[] getModelDataEvents() {
return null;
}
}
@@ -80,85 +81,80 @@ public class TestUiDataModel {
assertNull(_uiModelRoot.getLabelText());
assertTrue(_uiModelRoot.hasChildren());
+ /* test UiModelSession*/
+ IUiModelElement sessions[] = _uiModelRoot.getChildren();
+ assertNotNull(sessions);
+ assertEquals(3, sessions.length);
+ assertNotNull(sessions[0]);
+ assertNotNull(sessions[1]);
+ assertNotNull(sessions[2]);
+
+ assertEquals(TestingOpModelRoot.NAME_E1, sessions[0].toString());
+ assertEquals(TestingOpModelRoot.NAME_E1, sessions[0].getLabelText());
+ assertTrue(sessions[0].hasChildren());
+ assertNull(sessions[0].getParent()); //events are top level tree elements
+ assertNotNull(sessions[0].getLabelImage());
+
+ assertEquals(TestingOpModelRoot.NAME_E2, sessions[1].toString());
+ assertEquals(TestingOpModelRoot.NAME_E2, sessions[1].getLabelText());
+ assertTrue(sessions[1].hasChildren());
+ assertNull(sessions[1].getParent()); //events are top level tree elements
+ assertNotNull(sessions[1].getLabelImage());
+
+
/* test UiModelEvent */
- IUiModelElement events[] = _uiModelRoot.getChildren();
- assertNotNull(events);
- assertEquals(3, events.length);
- assertNotNull(events[0]);
- assertNotNull(events[1]);
- assertNotNull(events[2]);
-
- assertEquals(TestingOpModelRoot.NAME_E1, events[0].toString());
- assertEquals(TestingOpModelRoot.NAME_E1, events[0].getLabelText());
- assertTrue(events[0].hasChildren());
- assertNull(events[0].getParent()); //events are top level tree elements
- assertNotNull(events[0].getLabelImage());
-
- assertEquals(TestingOpModelRoot.NAME_E2, events[1].toString());
- assertEquals(TestingOpModelRoot.NAME_E2, events[1].getLabelText());
- assertTrue(events[1].hasChildren());
- assertNull(events[1].getParent()); //events are top level tree elements
- assertNotNull(events[1].getLabelImage());
-
- assertTrue(events[2].toString().isEmpty());
- assertTrue(events[2].getLabelText().isEmpty());
- assertFalse(events[2].hasChildren());
- assertNull(events[2].getParent()); //events are top level tree elements
- assertNotNull(events[2].getLabelImage());
-
- /* test UiModelSession */
- IUiModelElement[] e1_sessions = events[0].getChildren(), e2_sessions = events[1].getChildren();
- assertNotNull(e1_sessions);
- assertNotNull(e2_sessions);
- assertEquals(1, e1_sessions.length);
- assertEquals(4, e2_sessions.length);
- assertNotNull(e1_sessions[0]);
- assertNotNull(e2_sessions[0]);
- assertNotNull(e2_sessions[1]);
- assertNotNull(e2_sessions[2]);
- assertNotNull(e2_sessions[3]);
-
- assertEquals(TestingOpModelRoot.NAME_E1_S1, e1_sessions[0].toString());
- assertEquals(TestingOpModelRoot.NAME_E1_S1, e1_sessions[0].getLabelText());
- assertFalse(((UiModelSession)e1_sessions[0]).isDefaultSession());
- assertTrue(e1_sessions[0].hasChildren());
- assertEquals(events[0], e1_sessions[0].getParent());
- assertNotNull(e1_sessions[0].getLabelImage());
-
- assertEquals(TestingOpModelRoot.NAME_E2_S1, e2_sessions[0].toString());
- assertEquals(TestingOpModelRoot.NAME_E2_S1, e2_sessions[0].getLabelText());
- assertFalse(((UiModelSession)e2_sessions[0]).isDefaultSession());
- assertTrue(e2_sessions[0].hasChildren());
- assertEquals(events[1], e2_sessions[0].getParent());
- assertNotNull(e2_sessions[0].getLabelImage());
-
- assertEquals(TestingOpModelRoot.NAME_E2_S2, e2_sessions[1].toString());
- assertEquals(TestingOpModelRoot.NAME_E2_S2, e2_sessions[1].getLabelText());
- assertFalse(((UiModelSession)e2_sessions[1]).isDefaultSession());
- assertTrue(e2_sessions[1].hasChildren());
- assertEquals(events[1], e2_sessions[1].getParent());
- assertNotNull(e2_sessions[1].getLabelImage());
-
- assertEquals(TestingOpModelRoot.NAME_E2_S3, e2_sessions[2].toString());
- assertEquals(TestingOpModelRoot.NAME_E2_S3, e2_sessions[2].getLabelText());
- assertFalse(((UiModelSession)e2_sessions[2]).isDefaultSession());
- assertTrue(e2_sessions[2].hasChildren());
- assertEquals(events[1], e2_sessions[2].getParent());
- assertNotNull(e2_sessions[2].getLabelImage());
-
- assertEquals(TestingOpModelRoot.NAME_E2_S4, e2_sessions[3].toString());
- assertEquals(TestingOpModelRoot.NAME_E2_S4, e2_sessions[3].getLabelText());
- assertFalse(((UiModelSession)e2_sessions[3]).isDefaultSession());
- assertFalse(e2_sessions[3].hasChildren());
- assertEquals(events[1], e2_sessions[3].getParent());
- assertNotNull(e2_sessions[3].getLabelImage());
+ IUiModelElement[] e1_events = sessions[0].getChildren(), e2_events = sessions[1].getChildren();
+ assertNotNull(e1_events);
+ assertNotNull(e2_events);
+ assertEquals(1, e1_events.length);
+ assertEquals(4, e2_events.length);
+ assertNotNull(e1_events[0]);
+ assertNotNull(e2_events[0]);
+ assertNotNull(e2_events[1]);
+ assertNotNull(e2_events[2]);
+ assertNotNull(e2_events[3]);
+
+ assertEquals(TestingOpModelRoot.NAME_E1_S1, e1_events[0].toString());
+ assertEquals(TestingOpModelRoot.NAME_E1_S1, e1_events[0].getLabelText());
+ assertFalse(((UiModelSession)e1_events[0].getParent()).isDefaultSession());
+ assertTrue(e1_events[0].hasChildren());
+ assertEquals(sessions[0], e1_events[0].getParent());
+ assertNotNull(e1_events[0].getLabelImage());
+
+ assertEquals(TestingOpModelRoot.NAME_E2_S1, e2_events[0].toString());
+ assertEquals(TestingOpModelRoot.NAME_E2_S1, e2_events[0].getLabelText());
+ assertFalse(((UiModelSession)e2_events[0].getParent()).isDefaultSession());
+ assertTrue(e2_events[0].hasChildren());
+ assertEquals(sessions[1], e2_events[0].getParent());
+ assertNotNull(e2_events[0].getLabelImage());
+
+ assertEquals(TestingOpModelRoot.NAME_E2_S2, e2_events[1].toString());
+ assertEquals(TestingOpModelRoot.NAME_E2_S2, e2_events[1].getLabelText());
+ assertFalse(((UiModelSession)e2_events[1].getParent()).isDefaultSession());
+ assertTrue(e2_events[1].hasChildren());
+ assertEquals(sessions[1], e2_events[1].getParent());
+ assertNotNull(e2_events[1].getLabelImage());
+
+ assertEquals(TestingOpModelRoot.NAME_E2_S3, e2_events[2].toString());
+ assertEquals(TestingOpModelRoot.NAME_E2_S3, e2_events[2].getLabelText());
+ assertFalse(((UiModelSession)e2_events[2].getParent()).isDefaultSession());
+ assertTrue(e2_events[2].hasChildren());
+ assertEquals(sessions[1], e2_events[2].getParent());
+ assertNotNull(e2_events[2].getLabelImage());
+
+ assertEquals(TestingOpModelRoot.NAME_E2_S4, e2_events[3].toString());
+ assertEquals(TestingOpModelRoot.NAME_E2_S4, e2_events[3].getLabelText());
+ assertFalse(((UiModelSession)e2_events[3].getParent()).isDefaultSession());
+ assertFalse(e2_events[3].hasChildren());
+ assertEquals(sessions[1], e2_events[3].getParent());
+ assertNotNull(e2_events[3].getLabelImage());
/* test UiModelImage and UiModelDependent */
- IUiModelElement[] e1_s1_images = e1_sessions[0].getChildren(),
- e2_s1_images = e2_sessions[0].getChildren(),
- e2_s2_images = e2_sessions[1].getChildren(),
- e2_s3_images = e2_sessions[2].getChildren(),
- e2_s4_images = e2_sessions[3].getChildren();
+ IUiModelElement[] e1_s1_images = e1_events[0].getChildren(),
+ e2_s1_images = e2_events[0].getChildren(),
+ e2_s2_images = e2_events[1].getChildren(),
+ e2_s3_images = e2_events[2].getChildren(),
+ e2_s4_images = e2_events[3].getChildren();
assertNotNull(e1_s1_images);
assertNotNull(e2_s1_images);
@@ -182,37 +178,37 @@ public class TestUiDataModel {
assertNotNull(e1_s1_images[0].toString());
assertNotNull(e1_s1_images[0].getLabelText());
assertTrue(e1_s1_images[0].hasChildren());
- assertEquals(e1_sessions[0], e1_s1_images[0].getParent());
+ assertEquals(e1_events[0], e1_s1_images[0].getParent());
assertNotNull(e1_s1_images[0].getLabelImage());
assertNotNull(e1_s1_images[1].toString());
assertNotNull(e1_s1_images[1].getLabelText());
assertTrue(e1_s1_images[1].hasChildren());
- assertEquals(e1_sessions[0], e1_s1_images[1].getParent());
+ assertEquals(e1_events[0], e1_s1_images[1].getParent());
assertNotNull(e1_s1_images[1].getLabelImage());
assertNotNull(e2_s1_images[0].toString());
assertNotNull(e2_s1_images[0].getLabelText());
assertTrue(e2_s1_images[0].hasChildren());
- assertEquals(e2_sessions[0], e2_s1_images[0].getParent());
+ assertEquals(e2_events[0], e2_s1_images[0].getParent());
assertNotNull(e2_s1_images[0].getLabelImage());
assertNotNull(e2_s1_images[1].toString());
assertNotNull(e2_s1_images[1].getLabelText());
assertTrue(e2_s1_images[1].hasChildren());
- assertEquals(e2_sessions[0], e2_s1_images[1].getParent());
+ assertEquals(e2_events[0], e2_s1_images[1].getParent());
assertNotNull(e2_s1_images[1].getLabelImage());
assertNotNull(e2_s2_images[0].toString());
assertNotNull(e2_s2_images[0].getLabelText());
assertTrue(e2_s2_images[0].hasChildren());
- assertEquals(e2_sessions[1], e2_s2_images[0].getParent());
+ assertEquals(e2_events[1], e2_s2_images[0].getParent());
assertNotNull(e2_s2_images[0].getLabelImage());
assertNotNull(e2_s3_images[0].toString());
assertNotNull(e2_s3_images[0].getLabelText());
assertFalse(e2_s3_images[0].hasChildren());
- assertEquals(e2_sessions[2], e2_s3_images[0].getParent());
+ assertEquals(e2_events[2], e2_s3_images[0].getParent());
assertNotNull(e2_s3_images[0].getLabelImage());
/* test UiModelSymbol */
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF b/oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF
index 8b67ea8..66f8813 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/META-INF/MANIFEST.MF
@@ -20,4 +20,5 @@ Import-Package: org.eclipse.core.resources,
org.eclipse.jface.text,
org.eclipse.linuxtools.internal.oprofile.core,
org.eclipse.linuxtools.internal.oprofile.core.model,
+ org.eclipse.linuxtools.internal.oprofile.core.opxml.sessions,
org.eclipse.linuxtools.profiling.ui
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java
index d434ee2..98527d3 100755
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java
@@ -19,6 +19,7 @@ import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin;
+import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
import org.eclipse.linuxtools.oprofile.ui.model.UiModelSession;
public class OprofileViewDeleteSessionAction extends Action {
@@ -49,9 +50,15 @@ public class OprofileViewDeleteSessionAction extends Action {
*/
private void deleteSession(UiModelSession sess) {
String sessionName = sess.getLabelText();
- String eventName = sess.getParent().getLabelText();
+ IUiModelElement[] modelEvents = sess.getChildren();
try {
- OprofileCorePlugin.getDefault().getOpcontrolProvider().deleteSession(sessionName, eventName);
+ for (int i = 0; i < modelEvents.length; i++) {
+ OprofileCorePlugin
+ .getDefault()
+ .getOpcontrolProvider()
+ .deleteSession(sessionName,
+ modelEvents[i].getLabelText());
+ }
// clear out collected data by this session
// check if profile is done through operf or oprofile
if (Oprofile.OprofileProject.getProfilingBinary().equals(
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java
index 9d209c2..65da455 100755
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSaveDefaultSessionAction.java
@@ -23,6 +23,7 @@ import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
+import org.eclipse.linuxtools.internal.oprofile.core.opxml.sessions.SessionManager;
import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiMessages;
import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin;
import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
@@ -47,24 +48,24 @@ public class OprofileViewSaveDefaultSessionAction extends Action {
public void run() {
boolean defaultSessionExists = false;
String defaultSessionName = null;
- String eventName = null;
UiModelRoot modelRoot = UiModelRoot.getDefault();
+ IUiModelElement[] modelEvents = null;
if (modelRoot.hasChildren()) {
- IUiModelElement[] events = modelRoot.getChildren();
- for (IUiModelElement e : events) {
+ IUiModelElement[] sessions = modelRoot.getChildren();
+ for (IUiModelElement e : sessions) {
if (e instanceof UiModelError)
break;
- IUiModelElement[] sessions = e.getChildren();
- for (IUiModelElement s : sessions) {
- if (((UiModelSession)s).isDefaultSession()) {
+ if(e instanceof UiModelSession ){
+
+ if (((UiModelSession)e).isDefaultSession()) {
defaultSessionExists = true;
- defaultSessionName = s.getLabelText();
- eventName = s.getParent().getLabelText();
+ defaultSessionName = e.getLabelText();
+ modelEvents = ((UiModelSession)e).getChildren();
break;
}
- }
+
if (defaultSessionExists)
break;
}
@@ -83,7 +84,13 @@ public class OprofileViewSaveDefaultSessionAction extends Action {
try {
OprofileCorePlugin.getDefault().getOpcontrolProvider().saveSession(dialog.getValue());
// remove the default session
- OprofileCorePlugin.getDefault().getOpcontrolProvider().deleteSession(defaultSessionName, eventName);
+ for (int i = 0; i < modelEvents.length; i++) {
+ OprofileCorePlugin
+ .getDefault()
+ .getOpcontrolProvider()
+ .deleteSession(defaultSessionName,
+ modelEvents[i].getLabelText());
+ }
// clear out collected data by this session
// if opcontol is used
if (!Oprofile.OprofileProject.OPERF_BINARY
@@ -112,9 +119,17 @@ public class OprofileViewSaveDefaultSessionAction extends Action {
OprofileUiMessages.getString("defaultsessiondialog.nodefaultsession.message")); //$NON-NLS-1$
}
}
+ }
//Original author: Keith Seitz <keiths@redhat.com>
private class SaveSessionValidator implements IInputValidator {
+
+ private SessionManager session = null;
+ public SaveSessionValidator()
+ {
+ session = new SessionManager(SessionManager.SESSION_LOCATION);
+ }
+
@Override
public String isValid(String newText) {
// Sanity check
@@ -141,6 +156,13 @@ public class OprofileViewSaveDefaultSessionAction extends Action {
return MessageFormat.format(format, fmtArgs);
}
+ if(session.existsSession(newText))
+ {
+ String format = OprofileUiMessages.getString("savedialog.validator.exists"); //$NON-NLS-1$
+ Object[] fmtArgs = new Object[] { newText };
+ return MessageFormat.format(format, fmtArgs);
+ }
+
// Must not already exist (opcontrol doesn't allow it)
try {
@@ -161,5 +183,6 @@ public class OprofileViewSaveDefaultSessionAction extends Action {
}
};
+ }
+
-}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelEvent.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelEvent.java
index a622c12..2ba80f7 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelEvent.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelEvent.java
@@ -11,7 +11,7 @@
package org.eclipse.linuxtools.oprofile.ui.model;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
-import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
+import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage;
import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin;
import org.eclipse.swt.graphics.Image;
@@ -23,24 +23,29 @@ import org.eclipse.swt.graphics.Image;
public class UiModelEvent implements IUiModelElement {
private IUiModelElement parent = null; //parent node -- necessary?
private OpModelEvent event; //the node in the data model
- private UiModelSession sessions[]; //this node's children
- public UiModelEvent(OpModelEvent event) {
- if (event != null) {
- this.event = event;
- refreshModel();
- }
+ private UiModelImage image; //this node's child
+ private UiModelDependent dependent; //dependent images of the OpModelImage
+
+ public UiModelEvent(IUiModelElement parent, OpModelEvent event) {
+ this.parent = parent;
+ this.event = event;
+ this.image = null;
+ this.dependent = null;
+ refreshModel();
}
/**
* Create the ui sessions from the data model.
*/
private void refreshModel() {
- OpModelSession dataModelSessions[] = event.getSessions();
- sessions = new UiModelSession[dataModelSessions.length];
+ OpModelImage dataModelImage = event.getImage();
+ if (dataModelImage != null) {
+ image = new UiModelImage(this, dataModelImage, dataModelImage.getCount(), dataModelImage.getDepCount());
- for (int i = 0; i < dataModelSessions.length; i++) {
- sessions[i] = new UiModelSession(this, dataModelSessions[i]);
+ if (dataModelImage.hasDependents()) {
+ dependent = new UiModelDependent(this, dataModelImage.getDependents(), dataModelImage.getCount(), dataModelImage.getDepCount());
+ }
}
}
@@ -61,7 +66,11 @@ public class UiModelEvent implements IUiModelElement {
*/
@Override
public IUiModelElement[] getChildren() {
- return sessions;
+ if (dependent != null) {
+ return new IUiModelElement[] {image, dependent};
+ } else {
+ return new IUiModelElement[] {image};
+ }
}
/**
@@ -70,7 +79,7 @@ public class UiModelEvent implements IUiModelElement {
*/
@Override
public boolean hasChildren() {
- return (sessions == null || sessions.length == 0 ? false : true);
+ return (image != null);
}
/**
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java
index 486120d..97a24a4 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.linuxtools.oprofile.ui.model;
-import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot;
+import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
import org.eclipse.swt.graphics.Image;
/**
@@ -21,12 +21,13 @@ import org.eclipse.swt.graphics.Image;
*/
public class UiModelRoot implements IUiModelElement {
private static UiModelRoot uiModelRoot = new UiModelRoot(); //singleton
- private UiModelEvent[] events; //this node's children
+
private UiModelError rootError;
+ private UiModelSession[] session; //this node's children
/** constructor, private for singleton use **/
protected UiModelRoot() {
- events = null;
+ session = null;
rootError = null;
}
@@ -44,24 +45,25 @@ public class UiModelRoot implements IUiModelElement {
* the child elements from their constructor.
*/
public void refreshModel() {
- OpModelEvent dataModelEvents[] = getModelDataEvents();
+ OpModelSession dataModelEvents[] = getModelDataEvents();
+
rootError = null;
- events = null;
+ session = null;
if (dataModelEvents == null || dataModelEvents.length == 0) {
rootError = UiModelError.NO_SAMPLES_ERROR;
} else {
- events = new UiModelEvent[dataModelEvents.length];
+ session = new UiModelSession[dataModelEvents.length];
for (int i = 0; i < dataModelEvents.length; i++) {
- events[i] = new UiModelEvent(dataModelEvents[i]);
+ session[i] = new UiModelSession(dataModelEvents[i]);
}
}
}
- protected OpModelEvent[] getModelDataEvents() {
+ protected OpModelSession[] getModelDataEvents() {
OpModelRoot modelRoot = OpModelRoot.getDefault();
- return modelRoot.getEvents();
+ return modelRoot.getSessions();
}
/** IUiModelElement functions **/
@@ -76,8 +78,8 @@ public class UiModelRoot implements IUiModelElement {
*/
@Override
public IUiModelElement[] getChildren() {
- if (events != null)
- return events;
+ if (session != null && session.length != 0)
+ return session;
else
return new IUiModelElement[] { rootError };
}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java
index 46d5447..3223ffa 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java
@@ -10,7 +10,8 @@
*******************************************************************************/
package org.eclipse.linuxtools.oprofile.ui.model;
-import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage;
+import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent;
+import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot;
import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession;
import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiMessages;
import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin;
@@ -29,6 +30,8 @@ public class UiModelSession implements IUiModelElement {
private UiModelImage image; //this node's child
private UiModelDependent dependent; //dependent images of the OpModelImage
+ private UiModelEvent events[];
+
//OProfile's default session name
private static final String DEFAULT_SESSION_NAME = "current"; //$NON-NLS-1$
@@ -37,23 +40,26 @@ public class UiModelSession implements IUiModelElement {
* @param parent The parent element
* @param session Oprofile session node in the data model
*/
- public UiModelSession(IUiModelElement parent, OpModelSession session) {
- this.parent = parent;
- this.session = session;
- this.image = null;
- this.dependent = null;
+ public UiModelSession(OpModelSession session) {
+ if(session != null){
+ this.session = session;
refreshModel();
+ }
}
private void refreshModel() {
- OpModelImage dataModelImage = session.getImage();
- if (dataModelImage != null) {
- image = new UiModelImage(this, dataModelImage, dataModelImage.getCount(), dataModelImage.getDepCount());
- if (dataModelImage.hasDependents()) {
- dependent = new UiModelDependent(this, dataModelImage.getDependents(), dataModelImage.getCount(), dataModelImage.getDepCount());
- }
+ OpModelEvent dataModelEvents[] = session.getEvents();
+ events = new UiModelEvent[dataModelEvents.length];
+ for (int i = 0; i < dataModelEvents.length; i++) {
+ events[i] = new UiModelEvent(this, dataModelEvents[i]);
}
+
+ }
+
+ protected OpModelSession[] getModelDataSessions() {
+ OpModelRoot modelRoot = OpModelRoot.getDefault();
+ return modelRoot.getSessions();
}
@Override
@@ -87,11 +93,7 @@ public class UiModelSession implements IUiModelElement {
*/
@Override
public IUiModelElement[] getChildren() {
- if (dependent != null) {
- return new IUiModelElement[] {image, dependent};
- } else {
- return new IUiModelElement[] {image};
- }
+ return events;
}
/**
@@ -100,7 +102,7 @@ public class UiModelSession implements IUiModelElement {
*/
@Override
public boolean hasChildren() {
- return (image != null);
+ return (events == null || events.length == 0 ? false : true);
}
/**