diff options
199 files changed, 4486 insertions, 1259 deletions
diff --git a/analysis/org.eclipse.tracecompass.analysis.counters.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/counters/ui/swtbot/tests/CounterViewPinAndCloneTest.java b/analysis/org.eclipse.tracecompass.analysis.counters.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/counters/ui/swtbot/tests/CounterViewPinAndCloneTest.java index 9771778d33..8a050f3004 100644 --- a/analysis/org.eclipse.tracecompass.analysis.counters.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/counters/ui/swtbot/tests/CounterViewPinAndCloneTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.counters.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/counters/ui/swtbot/tests/CounterViewPinAndCloneTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Ericsson + * Copyright (c) 2018, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -13,8 +13,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.jdt.annotation.NonNull; import org.eclipse.swt.widgets.Widget; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; @@ -37,7 +35,7 @@ import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.linecharts.TmfCommonXAxisChartViewer; import org.eclipse.tracecompass.tmf.ui.views.TmfChartView; -import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IViewPart; import org.junit.Test; /** @@ -130,20 +128,9 @@ public class CounterViewPinAndCloneTest extends XYDataProviderBaseTest { /** * Test the behavior with two traces. - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testPinTwoTraces() throws InvocationTargetException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException { + public void testPinTwoTraces() { SWTBotView originalViewBot = getSWTBotView(); ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace(); @@ -200,10 +187,9 @@ public class CounterViewPinAndCloneTest extends XYDataProviderBaseTest { SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName()); assertOriginalViewTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE); - IWorkbenchPart part = originalViewBot.getViewReference().getPart(false); - assertTrue(part instanceof TmfChartView); - TmfChartView viewSite = (TmfChartView) part; - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + IViewPart viewPart = originalViewBot.getViewReference().getView(false); + assertTrue(viewPart instanceof TmfChartView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, kernelTrace)); @@ -231,20 +217,9 @@ public class CounterViewPinAndCloneTest extends XYDataProviderBaseTest { /** * Test the cloning feature. - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testCloneSingleTrace() throws InvocationTargetException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException { + public void testCloneSingleTrace() { SWTBotView originalViewBot = getSWTBotView(); SWTBotMenu cloneMenu = originalViewBot.viewMenu().menu(NEW_COUNTER_STACK_MENU); @@ -276,10 +251,9 @@ public class CounterViewPinAndCloneTest extends XYDataProviderBaseTest { // Assert that the cloned trace's window range did not change SWTBotUtils.activateEditor(fBot, cloneTrace.getName() + CLONED_TRACE_SUFFIX); - IWorkbenchPart part = clonedView.getViewReference().getPart(false); - assertTrue(part instanceof TmfChartView); - TmfChartView viewSite = (TmfChartView) part; - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + IViewPart viewPart = clonedView.getViewReference().getView(false); + assertTrue(viewPart instanceof TmfChartView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer)); diff --git a/analysis/org.eclipse.tracecompass.analysis.counters.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/counters/ui/swtbot/tests/CounterViewTest.java b/analysis/org.eclipse.tracecompass.analysis.counters.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/counters/ui/swtbot/tests/CounterViewTest.java index fac0971b10..519eadab8d 100644 --- a/analysis/org.eclipse.tracecompass.analysis.counters.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/counters/ui/swtbot/tests/CounterViewTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.counters.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/counters/ui/swtbot/tests/CounterViewTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Ericsson + * Copyright (c) 2017, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -14,8 +14,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.swt.graphics.RGB; @@ -87,25 +85,13 @@ public class CounterViewTest extends XYDataProviderBaseTest { /** * Validate the Counters view data model. - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testDisplayingDataSeries() throws NoSuchMethodException, SecurityException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException { + public void testDisplayingDataSeries() { // Setup the chart viewer - IViewPart viewSite = getSWTBotView().getViewReference().getView(true); - assertTrue(viewSite instanceof CounterView); - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + IViewPart viewPart = getSWTBotView().getViewReference().getView(true); + assertTrue(viewPart instanceof CounterView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer)); chartViewer.setNbPoints(NUMBER_OF_POINTS); diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java index f57b6dac21..a965a982de 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java @@ -69,7 +69,7 @@ public class TmfGraphStatistics implements ITmfGraphVisitor { @Override public void visit(TmfVertex node) { - + // Do nothing } @Override diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/dataprovider/CriticalPathEntry.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/dataprovider/CriticalPathEntry.java index 81f9004092..2ae5b3d18c 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/dataprovider/CriticalPathEntry.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/dataprovider/CriticalPathEntry.java @@ -28,6 +28,7 @@ import com.google.common.collect.Multimap; * @author Loic Prieur-Drevon */ public class CriticalPathEntry extends TimeGraphEntryModel implements IElementResolver { + private final Long fSum; private final Double fPercent; private final @NonNull Multimap<@NonNull String, @NonNull String> fAspects = HashMultimap.create(); @@ -113,4 +114,10 @@ public class CriticalPathEntry extends TimeGraphEntryModel implements IElementRe return fAspects; } + @Override + public boolean hasRowModel() { + // parent level entries do not have row models + return getParentId() != -1L; + } + } diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java index 7efad596ee..a288ffa82f 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathModuleListener.java @@ -24,7 +24,7 @@ public class CriticalPathModuleListener implements ITmfNewAnalysisModuleListener * Constructor */ public CriticalPathModuleListener() { - + // Do nothing } @Override diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF index 3ba07bb5c8..f70cd7ab90 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF @@ -24,6 +24,8 @@ Import-Package: com.google.common.base, com.google.common.collect, com.google.common.hash, com.google.common.primitives, + org.apache.commons.io, + org.apache.commons.io.input, org.apache.commons.lang3 Export-Package: org.eclipse.tracecompass.analysis.os.linux.core.contextswitch, org.eclipse.tracecompass.analysis.os.linux.core.cpuusage, diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/build.properties b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/build.properties index e9fe1cafaa..4fc0ffd035 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/build.properties +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/build.properties @@ -18,5 +18,6 @@ bin.includes = META-INF/,\ plugin.properties,\ plugin.xml,\ icons/,\ - schema/ + schema/,\ + res/ src.includes = about.html diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/res/syscalls.tsv b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/res/syscalls.tsv new file mode 100644 index 0000000000..0b26060624 --- /dev/null +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/res/syscalls.tsv @@ -0,0 +1,353 @@ +###############################################################################
+# Copyright (c) 2019 Ericsson
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+# Note: these files were painfully extracted by hand from the 4.20 kernel source tree
+# Code location should not be a GPL violation.
+Syscall Subsystem file
+accept net net/socket.c
+accept4 net net/socket.c
+access fs fs/open.c
+acct kernel kernel/acct.c
+add_key security security/keys/keyctl.c
+adjtimex kernel kernel/time.c
+alarm kernel kernel/sched.c set an alarm clock for delivery of a signal
+bdflush fs fs/buffer.c
+bind net net/socket.c
+brk mm mm/mmap.c
+chdir fs fs/open.c
+chmod fs fs/open.c
+chown fs fs/open.c
+chown16 fs fs/open.c
+chroot fs fs/open.c
+clock_adjtime kernel kernel/time.c
+clock_getres kernel kernel/time.c
+clock_gettime kernel kernel/time.c
+clock_nanosleep kernel kernel/sched.c
+clock_settime kernel kernel/time.c
+clone kernel kernel/fork.c
+close fs fs/open.c
+connect net net/socket.c
+creat fs fs/open.c
+delete_module kernel kernel/module.c
+dup fs fs/file.c
+dup2 fs fs/file.c
+dup3 fs fs/file.c
+epoll_create fs fs/eventpoll.c
+epoll_create1 fs fs/eventpoll.c
+epoll_ctl fs fs/eventpoll.c
+epoll_pwait fs fs/eventpoll.c
+epoll_wait fs fs/eventpoll.c
+eventfd fs fs/eventfd.c
+eventfd2 fs fs/eventfd.c
+execve fs fs/exec.c
+exit kernel kernel/exit.c
+exit_group kernel kernel/exit.c
+faccessat fs fs/open.c
+fadvise64 mm mm/fadvise.c
+fallocate fs fs/open.c
+fanotify_init fs fs/notify/fanotify/fanotify_user.c
+fanotify_mark fs fs/notify/fanotify/fanotify_user.c
+fchdir fs fs/open.c
+fchmod fs fs/open.c
+fchmodat fs fs/open.c
+fchown fs fs/open.c
+fchown16 fs fs/open.c
+fchownat fs fs/open.c
+fcntl fs fs/fcntl.c
+fcntl64 fs fs/fcntl.c
+fdatasync fs fs/sync.c
+fgetxattr fs fs/xattr.c
+finit_module kernel kernel/module.c
+flistxattr fs fs/xattr.c
+flock fs fs/locks.c
+fremovexattr fs fs/xattr.c
+fsetxattr fs fs/xattr.c
+fstat fs fs/stat.c
+fstat64 fs fs/stat.c
+fstatat64 fs fs/stat.c
+fstatfs fs fs/statfs.c
+fstatfs64 fs fs/statfs.c
+fsync fs fs/sync.c
+ftruncate fs fs/open.c
+futex kernel kernel/futex.c
+futimesat fs fs/utimes.c
+getcpu kernel kernel/sys.c
+getcwd fs fs/dcache.c
+getdents fs fs/readdir.c
+getdents64 fs fs/readdir.c
+getegid kernel kernel/sys.c
+getegid16 kernel kernel/sys.c
+geteuid kernel kernel/sys.c
+geteuid16 kernel kernel/sys.c
+getgid kernel kernel/sys.c
+getgid16 kernel kernel/sys.c
+getgroups kernel kernel/groups.c
+getgroups16 kernel kernel/groups.c
+getitimer kernel kernel/itimer.c
+get_mempolicy mm mm/mempolicy.c
+getpeername net net/socket.c
+getpgid kernel kernel/sys.c
+getpgrp kernel kernel/sys.c
+getpid kernel kernel/sys.c
+getppid kernel kernel/sys.c
+getpriority kernel kernel/sys.c
+getresgid kernel kernel/sys.c
+getresgid16 kernel kernel/sys.c
+getresuid kernel kernel/sys.c
+getresuid16 kernel kernel/sys.c
+getrlimit kernel kernel/sys.c
+get_robust_list kernel kernel/futex.c
+getrusage kernel kernel/sys.c
+getsid kernel kernel/sys.c
+getsockname net net/socket.c
+getsockopt net net/socket.c
+gettid kernel kernel/sys.c
+gettimeofday kernel kernel/time.c
+getuid kernel kernel/sys.c
+getuid16 kernel kernel/sys.c
+getxattr fs fs/xattr.c
+init_module kernel kernel/module.c
+inotify_add_watch fs fs/notify/inotify/inotify_user.c
+inotify_init fs fs/notify/inotify/inotify_user.c
+inotify_init1 fs fs/notify/inotify/inotify_user.c
+inotify_rm_watch fs fs/notify/inotify/inotify_user.c
+io_cancel fs fs/aio.c
+ioctl fs fs/ioctl.c
+io_destroy fs fs/aio.c
+io_getevents fs fs/aio.c
+ioprio_get fs fs/ioprio.c
+ioprio_set fs fs/ioprio.c
+io_setup fs fs/aio.c
+io_submit fs fs/aio.c
+ipc ipc ipc/ipc.c
+kexec_load kernel kernel/kexec.c
+keyctl security security/keys/keyctl.c
+kill kernel kernel/signal.c
+lchown fs fs/open.c
+lchown16 fs fs/open.c
+lgetxattr fs fs/xattr.c
+link fs fs/namei.c
+linkat fs fs/namei.c
+listen net net/socket.c
+listxattr fs fs/xattr.c
+llistxattr fs fs/xattr.c
+llseek fs fs/read_write.c
+lookup_dcookie fs fs/dcookies.c
+lremovexattr fs fs/xattr.c
+lseek fs fs/read_write.c
+lsetxattr fs fs/xattr.c
+lstat fs fs/stat.c
+lstat64 fs fs/stat.c
+madvise mm mm/madvise.c
+mbind mm mm/mempolicy.c
+migrate_pages mm mm/mempolicy.c
+mincore mm mm/mincore.c
+mkdir fs fs/namei.c
+mkdirat fs fs/namei.c
+mknod fs fs/namei.c
+mknodat fs fs/namei.c
+mlock mm mm/mlock.c
+mlockall mm mm/mlock.c
+mmap arch arch/x86/kernel
+mmap2 arch arch/x86/kernel
+modify_ldt fs fs/namespace.c
+mount fs fs/namespace.c
+move_pages mm mm/migrate.c
+mprotect mm mm/mprotect.c
+mq_getsetattr ipc ipc/memqueue.c
+mq_notify ipc ipc/memqueue.c
+mq_open ipc ipc/memqueue.c
+mq_timedreceive ipc ipc/memqueue.c
+mq_timedsend ipc ipc/memqueue.c
+mq_unlink ipc ipc/memqueue.c
+mremap mm mm/mmap.c
+msgctl ipc ipc/msg.c
+msgget ipc ipc/msg.c
+msgrcv ipc ipc/msg.c
+msgsnd ipc ipc/msg.c
+msync mm mm/msync.c
+munlock mm mm/mlock.c
+munlockall mm mm/mlock.c
+munmap mm mm/mmap.c
+name_to_handle_at fs fs/fhandle.c
+nanosleep kernel kernel/hrtimer.c
+newfstat fs fs/stat.c
+newfstatat fs fs/stat.c
+newlstat fs fs/stat.c
+newstat fs fs/stat.c
+newuname kernel kernel/sys.c
+nice sched sched/core.c
+old_getrlimit kernel kernel/sys.c
+old_mmap mm mm/mmap.c
+old_readdir fs fs/readdir.c
+old_select fs fs/select.c
+oldumount fs fs/namespace.c
+olduname fs fs/namespace.c
+open fs fs/open.c
+openat fs fs/open.c
+open_by_handle_at fs fs/fhandle.c
+pause kernel kernel/signal.c
+perf_event_open kernel kernel/events/core.c
+personality kernel kernel/exec_domain.c
+pipe fs fs/pipe.c
+pipe2 fs fs/pipe.c
+pivot_root fs fs/namespace.c
+poll fs fs/select.c
+ppoll fs fs/select.c
+prctl kernel kernel/sys.c
+pread64 fs fs/read_write.c
+preadv fs fs/read_write.c
+prlimit64 kernel kernel/sys.c
+process_vm_readv mm mm/process_vm_access.c
+process_vm_writev mm mm/process_vm_access.c
+pselect6 fs fs/select.c
+ptrace kernel kernel/ptrace.c
+pwrite64 fs fs/read_write.c
+pwritev fs fs/read_write.c
+quotactl fs fs/quota/quota.c
+read fs fs/read_write.c
+readahead mm mm/readahead.c
+readlink fs fs/stat.c
+readlinkat fs fs/stat.c
+readv fs fs/read_write.c
+reboot kernel kernel/reboot.c
+recvfrom net net/socket.c
+recvmmsg net net/socket.c
+recvmsg net net/socket.c
+remap_file_pages mm mm/fremap.c
+removexattr fs fs/xattr.c
+rename fs fs/namei.c
+renameat fs fs/namei.c
+request_key security security/keys/keyctl.c
+restart_syscall kernel kernel/signal.c
+rmdir fs fs/namei.c
+rt_sigaction kernel kernel/signal.c
+rt_sigpending kernel kernel/signal.c
+rt_sigprocmask kernel kernel/signal.c
+rt_sigqueueinfo kernel kernel/signal.c
+rt_sigsuspend kernel kernel/signal.c
+rt_sigtimedwait kernel kernel/signal.c
+rt_tgsigqueueinfo kernel kernel/signal.c
+sched_getaffinity sched sched/core.c
+sched_getparam sched sched/core.c
+sched_get_priority_max sched sched/core.c
+sched_get_priority_min sched sched/core.c
+sched_getscheduler sched sched/core.c
+sched_rr_get_interval sched sched/core.c
+sched_setaffinity sched sched/core.c
+sched_setparam sched sched/core.c
+sched_setscheduler sched sched/core.c
+sched_yield sched sched/core.c
+select fs fs/select.c
+semctl ipc ipc/sem.c
+semget ipc ipc/sem.c
+semop ipc ipc/sem.c
+semtimedop ipc ipc/sem.c
+sendfile fs fs/read_write.c
+sendfile64 fs fs/read_write.c
+sendmmsg net net/socket.c
+sendmsg net net/socket.c
+sendto net net/socket.c
+setdomainname kernel kernel/sys.c
+setfsgid kernel kernel/sys.c
+setfsgid16 kernel kernel/sys.c
+setfsuid kernel kernel/sys.c
+setfsuid16 kernel kernel/sys.c
+setgid kernel kernel/sys.c
+setgid16 kernel kernel/sys.c
+setgroups kernel kernel/sys.c
+setgroups16 kernel kernel/sys.c
+sethostname kernel kernel/sys.c
+setitimer kernel kernel/itimer.c
+set_mempolicy mm mm/mempolicy.c
+setns kernel kernel/nsproxy.c
+setpgid kernel kernel/sys.c
+setpriority kernel kernel/sys.c
+setregid kernel kernel/sys.c
+setregid16 kernel kernel/sys.c
+setresgid kernel kernel/sys.c
+setresgid16 kernel kernel/sys.c
+setresuid kernel kernel/sys.c
+setresuid16 kernel kernel/sys.c
+setreuid kernel kernel/sys.c
+setreuid16 kernel kernel/sys.c
+setrlimit kernel kernel/sys.c
+set_robust_list kernel kernel/futex.c
+setsid kernel kernel/sys.c
+setsockopt net net/socket.c
+set_tid_address kernel kernel/fork.c
+settimeofday kernel kernel/time.c
+setuid kernel kernel/sys.c
+setuid16 kernel kernel/sys.c
+setxattr fs fs/xattr.c
+sgetmask kernel kernel/signal.c
+shmat ipc ipc/shm.c
+shmctl ipc ipc/shm.c
+shmdt ipc ipc/shm.c
+shmget ipc ipc/shm.c
+shutdown net net/socket.c
+sigaltstack kernel kernel/signal.c
+signal kernel kernel/signal.c
+signalfd fs fs/signalfd.c
+signalfd4 fs fs/signalfd.c
+sigpending kernel kernel/signal.c
+sigprocmask kernel kernel/signal.c
+socket net net/socket.c
+socketcall net net/socket.c
+socketpair net net/socket.c
+splice fs fs/splice.c
+ssetmask kernel kernel/signal.c
+stat fs fs/stat.c
+stat64 fs fs/stat.c
+statfs fs fs/statfs.c
+statfs64 fs fs/statfs.c
+stime kernel kernel/sys.c
+swapoff mm mm/swapfile.c
+swapon mm mm/swapfile.c
+symlink fs fs/namei.c
+symlinkat fs fs/namei.c
+sync fs fs/sync.c
+sync_file_range fs fs/sync.c
+syncfs fs fs/sync.c
+sysctl kernel kernel/sysctl_binary.c
+sysfs fs fs/filesystems.c
+sysinfo kernel kernel/sys.c
+syslog kernel kernel/printk/printk.c
+tee fs fs/splice.c
+tgkill kernel kernel/signal.c
+time kernel kernel/time.c
+timer_create kernel kernel/posix-timers.c
+timer_delete kernel kernel/posix-timers.c
+timerfd_create fs fs/timerfd.c
+timerfd_gettime fs fs/timerfd.c
+timerfd_settime fs fs/timerfd.c
+timer_getoverrun kernel kernel/posix-timers.c
+timer_gettime kernel kernel/posix-timers.c
+timer_settime kernel kernel/posix-timers.c
+times kernel kernel/sys.c
+tkill kernel kernel/signal.c
+truncate fs fs/open.c
+umask kernel kernel/sys.c
+umount fs fs/namespace.c
+uname kernel kernel/sys.c
+unknown unknown unknown/unknown
+unlink fs fs/namei.c
+unlinkat fs fs/namei.c
+unshare kernel kernel/fork.c
+uselib fs fs/exec.c
+ustat fs fs/statfs.c
+utime fs fs/utimes.c
+utimensat fs fs/utimes.c
+utimes fs fs/utimes.c
+vhangup fs fs/open.c
+vmsplice fs fs/splice.c
+wait4 kernel kernel/exit.c
+waitid kernel kernel/exit.c
+waitpid kernel kernel/exit.c
+write fs fs/read_write.c
+writev fs fs/read_write.c
\ No newline at end of file diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/cpuusage/KernelCpuUsageAnalysis.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/cpuusage/KernelCpuUsageAnalysis.java index d8da3044a9..96ac649a89 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/cpuusage/KernelCpuUsageAnalysis.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/cpuusage/KernelCpuUsageAnalysis.java @@ -19,6 +19,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -147,7 +148,7 @@ public class KernelCpuUsageAnalysis extends TmfStateSystemAnalysisModule { } return Math.max(subAttributes.size(), cpus); } catch (AttributeNotFoundException e) { - Activator.getDefault().logError(e.getMessage(), e); + Activator.getDefault().logError("Error: getting number of core " + e.getMessage(), e); //$NON-NLS-1$ } } return -1; @@ -214,8 +215,8 @@ public class KernelCpuUsageAnalysis extends TmfStateSystemAnalysisModule { long countAtStart, countAtEnd; for (Entry<Integer, List<Integer>> entry : tidsPerCpu.entrySet()) { - int cpuNode = entry.getKey(); - List<Integer> tidNodes = entry.getValue(); + int cpuNode = Objects.requireNonNull(entry.getKey()); + List<Integer> tidNodes = Objects.requireNonNull(entry.getValue()); String curCpuName = cpuSs.getAttributeName(cpuNode); long cpuTotal = 0; diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/model/OsStrings.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/model/OsStrings.java index c356c14d58..4144289d15 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/model/OsStrings.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/model/OsStrings.java @@ -28,6 +28,10 @@ import java.util.Objects; */ public final class OsStrings { + private OsStrings() { + // Do nothing + } + /** * Get the string for the thread ID * diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/Activator.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/Activator.java index 08d26c726f..ad24111863 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/Activator.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/Activator.java @@ -12,7 +12,13 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.core; +import java.io.IOException; +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; import org.eclipse.jdt.annotation.Nullable; @@ -67,6 +73,24 @@ public class Activator extends Plugin { return plugin; } + + /** + * Gets the absolute path from a path relative to this plugin's root + * + * @param relativePath + * The path relative to this plugin + * @return The absolute path corresponding to this relative path + */ + public @Nullable IPath getAbsolutePath(Path relativePath) { + URL location = FileLocator.find(getBundle(), relativePath, null); + try { + IPath path = new Path(FileLocator.toFileURL(location).getPath()); + return path; + } catch (IOException e) { + return null; + } + } + // ------------------------------------------------------------------------ // Operators // ------------------------------------------------------------------------ diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/SyscallLookup.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/SyscallLookup.java new file mode 100644 index 0000000000..15fa81a9c0 --- /dev/null +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/SyscallLookup.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2019 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.analysis.os.linux.core; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.annotation.Nullable; + +/** + * System call lookup helper, reads a map of system call names and their file + * locations. System calls are ABIs and should remain static in location when + * they are created. + * + * @author Matthew Khouzam + */ +public final class SyscallLookup { + + private static final String SYSCALL_TSV_PATH = "res/syscalls.tsv"; //$NON-NLS-1$ + + private static @Nullable SyscallLookup sInstance = null; + + private final Map<String, String> fComponents = new HashMap<>(); + private final Map<String, String> fFiles = new HashMap<>(); + + /** + * Get the instance of the System call lookup. + * @return the instance + */ + public static SyscallLookup getInstance() { + SyscallLookup instance = sInstance; + if (instance == null) { + instance = create(); + sInstance = instance; + } + return instance; + } + + + @SuppressWarnings("null") + private static SyscallLookup create() { + try { + IPath path = Activator.getDefault().getAbsolutePath(new Path(SYSCALL_TSV_PATH)); + if (path != null) { + File file = path.toFile(); + if (!file.exists()) { + Activator.getDefault().logWarning("Syscall names not available!"); //$NON-NLS-1$ + return new SyscallLookup(Collections.emptyList()); + } + return new SyscallLookup(FileUtils.readLines(file, StandardCharsets.UTF_8.name())); + } + } catch (IOException e) { + Activator.getDefault().logError("Failed to read file", e); //$NON-NLS-1$ + } + return new SyscallLookup(Collections.emptyList()); + } + + private SyscallLookup(@Nullable List<@Nullable String> lines) { + if (lines != null) { + for (String line : lines) { + if (line == null || line.startsWith("#")) { //$NON-NLS-1$ + continue; + } + String[] components = line.split("\t"); //$NON-NLS-1$ + if (components.length > 2) { + String name = String.valueOf(components[0]); + fComponents.put(name, String.valueOf(components[1])); + fFiles.put(name, String.valueOf(components[2])); + } + } + } + } + + /** + * Get the component of the system call + * + * @param name + * system call + * @return the component name or {@link StringUtils#EMPTY} if not found + */ + public String getComponent(String name) { + return fComponents.getOrDefault(name, StringUtils.EMPTY); + } + + /** + * Get the file of the system call + * + * @param name + * system call + * @return the file name or {@link StringUtils#EMPTY} if not found + */ + public String getFile(String name) { + return fFiles.getOrDefault(name, StringUtils.EMPTY); + } +} diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java index b190d72e2e..51b1f6bd7f 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java @@ -26,7 +26,9 @@ import org.eclipse.tracecompass.analysis.os.linux.core.tid.TidAnalysisModule; import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout; import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace; import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisEventBasedModule; +import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IGroupingSegmentAspect; import org.eclipse.tracecompass.datastore.core.interval.IHTIntervalReader; +import org.eclipse.tracecompass.internal.analysis.os.linux.core.SyscallLookup; import org.eclipse.tracecompass.segmentstore.core.ISegment; import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; import org.eclipse.tracecompass.segmentstore.core.SegmentStoreFactory.SegmentStoreType; @@ -51,8 +53,14 @@ public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEvent private static final String RET_FIELD = "ret"; //$NON-NLS-1$ private static final int VERSION = 2; - private static final Collection<ISegmentAspect> BASE_ASPECTS = - ImmutableList.of(SyscallNameAspect.INSTANCE, SyscallTidAspect.INSTANCE, SyscallRetAspect.INSTANCE); + private static final Collection<ISegmentAspect> BASE_ASPECTS = ImmutableList.of(SyscallNameAspect.INSTANCE, SyscallTidAspect.INSTANCE, SyscallRetAspect.INSTANCE, SyscallComponentAspect.INSTANCE, SyscallFileAspect.INSTANCE); + + /** + * Constructor + */ + public SystemCallLatencyAnalysis() { + // do nothing + } @Override public String getId() { @@ -187,20 +195,25 @@ public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEvent private static final class SyscallNameAspect implements ISegmentAspect { public static final ISegmentAspect INSTANCE = new SyscallNameAspect(); - private SyscallNameAspect() { } + private SyscallNameAspect() { + // Do nothing + } @Override public String getHelpText() { return checkNotNull(Messages.SegmentAspectHelpText_SystemCall); } + @Override public String getName() { return checkNotNull(Messages.SegmentAspectName_SystemCall); } + @Override public @Nullable Comparator<?> getComparator() { return null; } + @Override public @Nullable String resolve(ISegment segment) { if (segment instanceof SystemCall) { @@ -213,20 +226,25 @@ public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEvent private static final class SyscallTidAspect implements ISegmentAspect { public static final ISegmentAspect INSTANCE = new SyscallTidAspect(); - private SyscallTidAspect() { } + private SyscallTidAspect() { + // Do nothing + } @Override public String getHelpText() { return checkNotNull(Messages.SegmentAspectHelpText_SystemCallTid); } + @Override public String getName() { return OsStrings.tid(); } + @Override public @Nullable Comparator<?> getComparator() { return null; } + @Override public @Nullable Integer resolve(ISegment segment) { if (segment instanceof SystemCall) { @@ -236,30 +254,98 @@ public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEvent } } + private static final class SyscallComponentAspect implements IGroupingSegmentAspect { + public static final ISegmentAspect INSTANCE = new SyscallComponentAspect(); + + private SyscallComponentAspect() { + // Do nothing + } + + @Override + public String getName() { + return "Component"; //$NON-NLS-1$ + } + + @Override + public String getHelpText() { + return "Code Component that this system call belongs to"; //$NON-NLS-1$ + } + + @Override + public @Nullable Comparator<?> getComparator() { + return null; + } + + @Override + public @Nullable Object resolve(ISegment segment) { + if (segment instanceof SystemCall) { + return SyscallLookup.getInstance().getComponent(((SystemCall) segment).getName()); + } + return EMPTY_STRING; + } + } + private static final class SyscallRetAspect implements ISegmentAspect { public static final ISegmentAspect INSTANCE = new SyscallRetAspect(); - private SyscallRetAspect() { } + private SyscallRetAspect() { + // Do nothing + } @Override public String getHelpText() { return checkNotNull(Messages.SegmentAspectHelpText_SystemCallRet); } + @Override public String getName() { return checkNotNull(Messages.SegmentAspectName_SystemCallRet); } + + @Override + public @Nullable Object resolve(ISegment segment) { + if (segment instanceof SystemCall) { + return ((SystemCall) segment).getReturnValue(); + } + return EMPTY_STRING; + } + @Override public @Nullable Comparator<?> getComparator() { return null; } + + } + + private static final class SyscallFileAspect implements ISegmentAspect { + public static final ISegmentAspect INSTANCE = new SyscallFileAspect(); + + private SyscallFileAspect() { + // Do nothing + } + @Override - public @Nullable Integer resolve(ISegment segment) { + public String getName() { + return "File"; //$NON-NLS-1$ + } + + @Override + public String getHelpText() { + return "File that implements the system call"; //$NON-NLS-1$ + } + + @Override + public @Nullable Comparator<?> getComparator() { + return null; + } + + @Override + public @Nullable Object resolve(ISegment segment) { if (segment instanceof SystemCall) { - return ((SystemCall) segment).getReturnValue(); + return SyscallLookup.getInstance().getFile(((SystemCall) segment).getName()); } - return -1; + return EMPTY_STRING; } - } + } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/Messages.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/Messages.java index 1c80a30dcc..5ccb982ebf 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/Messages.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/Messages.java @@ -46,8 +46,6 @@ class Messages extends NLS { public static String CpuEntry; /** Frequency entry */ public static String FrequencyEntry; - /** cpu name */ - public static String ResourcesStatusDataProvider_attributeCpuName; /** irq name */ public static String ResourcesStatusDataProvider_attributeIrqName; /** soft irq name */ diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesEntryModel.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesEntryModel.java index 177d7e4bd9..39814fc450 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesEntryModel.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesEntryModel.java @@ -12,14 +12,19 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus import java.util.List; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.tracecompass.analysis.os.linux.core.model.OsStrings; +import org.eclipse.tracecompass.tmf.core.model.timegraph.IElementResolver; import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Multimap; + /** * {@link TimeGraphEntryModel} for the Resources Status data provider. * * @author Loic Prieur-Drevon */ -public class ResourcesEntryModel extends TimeGraphEntryModel { +public class ResourcesEntryModel extends TimeGraphEntryModel implements IElementResolver { /** Type of entry */ public enum Type { @@ -40,6 +45,8 @@ public class ResourcesEntryModel extends TimeGraphEntryModel { private final int fResourceId; private final Type fType; + private final @NonNull Multimap<@NonNull String, @NonNull String> fAspects; + /** * Constructor * @@ -62,6 +69,20 @@ public class ResourcesEntryModel extends TimeGraphEntryModel { super(id, parentId, labels, startTime, endTime, !labels.isEmpty()); fResourceId = resourceId; fType = type; + switch (type) { + case CPU: // resourceID is CPU, fall-through + case CURRENT_THREAD: // resourceID is CPU, fall-through + case FREQUENCY: // resourceID is CPU, fall-through + fAspects = ImmutableMultimap.of(OsStrings.cpu(), String.valueOf(resourceId)); + break; + case IRQ: + case SOFT_IRQ: // Fall-through + case GROUP: // Fall-through + default: + fAspects = ImmutableMultimap.of(); + break; + + } } /** @@ -81,4 +102,10 @@ public class ResourcesEntryModel extends TimeGraphEntryModel { public Type getType() { return fType; } + + @Override + public @NonNull Multimap<@NonNull String, @NonNull String> getMetadata() { + return fAspects; + } + } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesStatusDataProvider.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesStatusDataProvider.java index 6ec4425a5d..2caa7beca3 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesStatusDataProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesStatusDataProvider.java @@ -621,7 +621,7 @@ public class ResourcesStatusDataProvider extends AbstractTimeGraphDataProvider<@ if (!cpuList.isEmpty()) { Collections.sort(cpuList, (s1, s2) -> Integer.compare(Integer.parseInt(s1), Integer.parseInt(s2))); - retMap.put(Messages.ResourcesStatusDataProvider_attributeCpuName, String.join(", ", cpuList)); //$NON-NLS-1$ + retMap.put(OsStrings.cpu(), String.join(", ", cpuList)); //$NON-NLS-1$ } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/messages.properties b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/messages.properties index b768ae6b52..987163ef66 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/messages.properties +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/messages.properties @@ -26,7 +26,6 @@ SoftIrqLabelProvider_Unknown=unknown ThreadEntry=CPU {0} Threads CpuEntry=CPU {0} States FrequencyEntry=CPU {0} Frequency -ResourcesStatusDataProvider_attributeCpuName=CPU ResourcesStatusDataProvider_attributeIrqName=IRQ ResourcesStatusDataProvider_attributeSoftIrqName=SOFT IRQ ResourcesStatusDataProvider_attributeTidName=TID diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/Messages.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/Messages.java index 5c1689d22b..49421eed8d 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/Messages.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/Messages.java @@ -17,9 +17,6 @@ import org.eclipse.osgi.util.NLS; class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.messages"; //$NON-NLS-1$ - /** attribute cpu name */ - public static String ThreadStatusDataProvider_attributeCpuName; - /** The data provider title text */ public static String ThreadStatusDataProviderFactory_title; /** diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadEntryModel.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadEntryModel.java index c493ea2e35..06a06a3f1f 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadEntryModel.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadEntryModel.java @@ -206,4 +206,10 @@ public class ThreadEntryModel extends TimeGraphEntryModel implements IElementRes return fAspects; } + @Override + public boolean hasRowModel() { + // parent level entries do not have row models + return getParentId() != -1L; + } + } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadStatusDataProvider.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadStatusDataProvider.java index 0221a0e525..128558b2ec 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadStatusDataProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/ThreadStatusDataProvider.java @@ -30,6 +30,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule; +import org.eclipse.tracecompass.analysis.os.linux.core.model.OsStrings; import org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator; import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes; import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.StateValues; @@ -667,7 +668,7 @@ public class ThreadStatusDataProvider extends AbstractTmfTraceDataProvider imple ITmfStateInterval interval = ss.querySingleState(start, currentCpuRqQuark); Object value = interval.getValue(); if (value instanceof Integer) { - return new TmfModelResponse<>(ImmutableMap.of(Messages.ThreadStatusDataProvider_attributeCpuName, String.valueOf(value)), status, statusMessage); + return new TmfModelResponse<>(ImmutableMap.of(OsStrings.cpu(), String.valueOf(value)), status, statusMessage); } } catch (StateSystemDisposedException e) { /* Ignored */ @@ -717,8 +718,17 @@ public class ThreadStatusDataProvider extends AbstractTmfTraceDataProvider imple @Override public @NonNull Multimap<@NonNull String, @NonNull String> getFilterData(long entryId, long time, @Nullable IProgressMonitor monitor) { - return ITimeGraphStateFilter.mergeMultimaps(ITimeGraphDataProvider.super.getFilterData(entryId, time, monitor), + Multimap<@NonNull String, @NonNull String> data = ITimeGraphStateFilter.mergeMultimaps(ITimeGraphDataProvider.super.getFilterData(entryId, time, monitor), fEntryMetadata.getOrDefault(entryId, ImmutableMultimap.of())); + SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(Collections.singletonList(time), Collections.singleton(Objects.requireNonNull(entryId))); + TmfModelResponse<Map<String, String>> response = fetchTooltip(filter, monitor); + Map<@NonNull String, @NonNull String> model = response.getModel(); + if (model != null) { + for (Entry<String, String> entry : model.entrySet()) { + data.put(entry.getKey(), entry.getValue()); + } + } + return data; } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/messages.properties b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/messages.properties index 63f13dbd3e..199ce2d250 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/messages.properties +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/threadstatus/messages.properties @@ -7,6 +7,5 @@ # http://www.eclipse.org/legal/epl-v10.html ############################################################################### -ThreadStatusDataProvider_attributeCpuName=CPU ThreadStatusDataProviderFactory_title=Thread Status ThreadStatusDataProviderFactory_descriptionText=Show the hierarchy of Linux threads and their status (RUNNING, SYSCALL, IRQ, IDLE) diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyScatterChartViewTest.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyScatterChartViewTest.java index f577ccf309..d8ea240324 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyScatterChartViewTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyScatterChartViewTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2017 Ericsson + * Copyright (c) 2016, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -16,8 +16,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.jdt.annotation.NonNull; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; @@ -61,25 +59,14 @@ public class SystemCallLatencyScatterChartViewTest extends XYDataProviderBaseTes * should be empty. * * TODO: Test the data - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testWithTrace() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public void testWithTrace() { // Wait for analysis to finish. WaitUtils.waitForJobs(); - IViewPart viewSite = getSWTBotView().getViewReference().getView(true); - assertTrue(viewSite instanceof SystemCallLatencyScatterView); - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + IViewPart viewPart = getSWTBotView().getViewReference().getView(true); + assertTrue(viewPart instanceof SystemCallLatencyScatterView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer)); diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyTableAnalysisTest.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyTableAnalysisTest.java index 372c93c710..abe5317647 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyTableAnalysisTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyTableAnalysisTest.java @@ -156,28 +156,28 @@ public class SystemCallLatencyTableAnalysisTest extends SegmentTableTest { protected void testTsv(String[] lines) { assertNotNull(lines); assertEquals("number of lines", 21, lines.length); - assertEquals("header", "Start Time\tEnd Time\tDuration\tSystem Call\tTID\tReturn value", lines[0]); + assertEquals("header", "Start Time\tEnd Time\tDuration\tSystem Call\tTID\tReturn value\tComponent\tFile", lines[0]); // not a straight up string compare due to time zones. Kathmandu and // Eucla have 15 minute time zones. - assertTrue("line 1 : " + lines[1], lines[1].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s001\\t\\d\\d:\\d\\d:00.000 000 002\\t1\\tleftpad\\t10\\t1")); - assertTrue("line 2 : " + lines[2], lines[2].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s002\\t\\d\\d:\\d\\d:00.000 000 006\\t4\\tleftpad\\t10\\t1")); - assertTrue("line 3 : " + lines[3], lines[3].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s003\\t\\d\\d:\\d\\d:00.000 000 012\\t9\\trightpad\\t10\\t1")); - assertTrue("line 4 : " + lines[4], lines[4].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s004\\t\\d\\d:\\d\\d:00.000 000 020\\t16\\tleftpad\\t10\\t1")); - assertTrue("line 5 : " + lines[5], lines[5].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s005\\t\\d\\d:\\d\\d:00.000 000 030\\t25\\tleftpad\\t10\\t1")); - assertTrue("line 6 : " + lines[6], lines[6].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s006\\t\\d\\d:\\d\\d:00.000 000 042\\t36\\trightpad\\t10\\t1")); - assertTrue("line 7 : " + lines[7], lines[7].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s007\\t\\d\\d:\\d\\d:00.000 000 056\\t49\\tleftpad\\t10\\t1")); - assertTrue("line 8 : " + lines[8], lines[8].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s008\\t\\d\\d:\\d\\d:00.000 000 072\\t64\\tleftpad\\t10\\t1")); - assertTrue("line 9 : " + lines[9], lines[9].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s009\\t\\d\\d:\\d\\d:00.000 000 090\\t81\\trightpad\\t10\\t1")); - assertTrue("line 10 : " + lines[10], lines[10].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s010\\t\\d\\d:\\d\\d:00.000 000 110\\t100\\tleftpad\\t10\\t1")); - assertTrue("line 11 : " + lines[11], lines[11].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s011\\t\\d\\d:\\d\\d:00.000 000 132\\t121\\tleftpad\\t10\\t1")); - assertTrue("line 12 : " + lines[12], lines[12].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s012\\t\\d\\d:\\d\\d:00.000 000 156\\t144\\trightpad\\t10\\t1")); - assertTrue("line 13 : " + lines[13], lines[13].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s013\\t\\d\\d:\\d\\d:00.000 000 182\\t169\\tleftpad\\t10\\t1")); - assertTrue("line 14 : " + lines[14], lines[14].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s014\\t\\d\\d:\\d\\d:00.000 000 210\\t196\\tleftpad\\t10\\t1")); - assertTrue("line 15 : " + lines[15], lines[15].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s015\\t\\d\\d:\\d\\d:00.000 000 240\\t225\\trightpad\\t10\\t1")); - assertTrue("line 16 : " + lines[16], lines[16].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s016\\t\\d\\d:\\d\\d:00.000 000 272\\t256\\tleftpad\\t10\\t1")); - assertTrue("line 17 : " + lines[17], lines[17].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s017\\t\\d\\d:\\d\\d:00.000 000 306\\t289\\tleftpad\\t10\\t1")); - assertTrue("line 18 : " + lines[18], lines[18].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s018\\t\\d\\d:\\d\\d:00.000 000 342\\t324\\trightpad\\t10\\t1")); - assertTrue("line 19 : " + lines[19], lines[19].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s019\\t\\d\\d:\\d\\d:00.000 000 380\\t361\\tleftpad\\t10\\t1")); - assertTrue("line 20 : " + lines[20], lines[20].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s020\\t\\d\\d:\\d\\d:00.000 000 420\\t400\\tleftpad\\t10\\t1")); + assertTrue("line 1 : " + lines[1], lines[1].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s001\\t\\d\\d:\\d\\d:00.000 000 002\\t1\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 2 : " + lines[2], lines[2].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s002\\t\\d\\d:\\d\\d:00.000 000 006\\t4\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 3 : " + lines[3], lines[3].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s003\\t\\d\\d:\\d\\d:00.000 000 012\\t9\\trightpad\\t10\\t1\\t\\t")); + assertTrue("line 4 : " + lines[4], lines[4].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s004\\t\\d\\d:\\d\\d:00.000 000 020\\t16\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 5 : " + lines[5], lines[5].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s005\\t\\d\\d:\\d\\d:00.000 000 030\\t25\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 6 : " + lines[6], lines[6].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s006\\t\\d\\d:\\d\\d:00.000 000 042\\t36\\trightpad\\t10\\t1\\t\\t")); + assertTrue("line 7 : " + lines[7], lines[7].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s007\\t\\d\\d:\\d\\d:00.000 000 056\\t49\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 8 : " + lines[8], lines[8].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s008\\t\\d\\d:\\d\\d:00.000 000 072\\t64\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 9 : " + lines[9], lines[9].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s009\\t\\d\\d:\\d\\d:00.000 000 090\\t81\\trightpad\\t10\\t1\\t\\t")); + assertTrue("line 10 : " + lines[10], lines[10].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s010\\t\\d\\d:\\d\\d:00.000 000 110\\t100\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 11 : " + lines[11], lines[11].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s011\\t\\d\\d:\\d\\d:00.000 000 132\\t121\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 12 : " + lines[12], lines[12].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s012\\t\\d\\d:\\d\\d:00.000 000 156\\t144\\trightpad\\t10\\t1\\t\\t")); + assertTrue("line 13 : " + lines[13], lines[13].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s013\\t\\d\\d:\\d\\d:00.000 000 182\\t169\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 14 : " + lines[14], lines[14].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s014\\t\\d\\d:\\d\\d:00.000 000 210\\t196\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 15 : " + lines[15], lines[15].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s015\\t\\d\\d:\\d\\d:00.000 000 240\\t225\\trightpad\\t10\\t1\\t\\t")); + assertTrue("line 16 : " + lines[16], lines[16].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s016\\t\\d\\d:\\d\\d:00.000 000 272\\t256\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 17 : " + lines[17], lines[17].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s017\\t\\d\\d:\\d\\d:00.000 000 306\\t289\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 18 : " + lines[18], lines[18].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s018\\t\\d\\d:\\d\\d:00.000 000 342\\t324\\trightpad\\t10\\t1\\t\\t")); + assertTrue("line 19 : " + lines[19], lines[19].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s019\\t\\d\\d:\\d\\d:00.000 000 380\\t361\\tleftpad\\t10\\t1\\t\\t")); + assertTrue("line 20 : " + lines[20], lines[20].matches("\\d\\d:\\d\\d:00\\.000\\s000\\s020\\t\\d\\d:\\d\\d:00.000 000 420\\t400\\tleftpad\\t10\\t1\\t\\t")); } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java index 1166f553aa..8491de458b 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java @@ -44,7 +44,7 @@ public class SystemCallLatencyDensityView extends AbstractSegmentStoreDensityVie protected void createProviderColumns() { super.createProviderColumns(); Table t = (Table) getControl(); - t.setColumnOrder(new int[] { 2, 3, 4, 5, 0, 1 }); + t.setColumnOrder(new int[] { 2, 3, 4, 5, 0, 1, 6, 7}); } }; } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/IGroupingSegmentAspect.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/IGroupingSegmentAspect.java new file mode 100644 index 0000000000..348ecba04b --- /dev/null +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/IGroupingSegmentAspect.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2018 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.tracecompass.analysis.timing.core.segmentstore; + +import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect; + +/** + * Tagging aspect to tell views that this is a category to group by + * + * @author Matthew Khouzam + * @since 5.0 + * + */ +public interface IGroupingSegmentAspect extends ISegmentAspect { + +} diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/ISegmentStoreProvider.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/ISegmentStoreProvider.java index 4a1d429a8f..242c53d37c 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/ISegmentStoreProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/ISegmentStoreProvider.java @@ -9,11 +9,19 @@ package org.eclipse.tracecompass.analysis.timing.core.segmentstore; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.segmentstore.core.IContentSegment; import org.eclipse.tracecompass.segmentstore.core.ISegment; import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + /** * Segment store provider. Useful to populate views. * @@ -54,4 +62,33 @@ public interface ISegmentStoreProvider { */ @Nullable ISegmentStore<ISegment> getSegmentStore(); + /** + * Get the map of segment data to filter on, using the provider's aspect and + * the segment's own data + * + * @param provider + * The segment store provider + * @param segment + * The segment to get the data from + * @return A multimap of key, values that represent the data of this segment + * @since 5.0 + */ + static Multimap<String, String> getFilterInput(ISegmentStoreProvider provider, ISegment segment) { + Multimap<String, String> map = HashMultimap.create(); + for (ISegmentAspect aspect : provider.getSegmentAspects()) { + Object resolve = aspect.resolve(segment); + if (resolve != null) { + map.put(aspect.getName(), String.valueOf(resolve)); + } + } + if (segment instanceof IContentSegment) { + // Add the content of the segment as key, value to filter on + Map<String, @NonNull ?> content = ((IContentSegment) segment).getContent(); + for (Entry<String, ?> val : content.entrySet()) { + map.put(val.getKey(), String.valueOf(val.getValue())); + } + } + return map; + } + }
\ No newline at end of file diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/SegmentStoreScatterDataProvider.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/SegmentStoreScatterDataProvider.java index 814e72042e..c6331c5e24 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/SegmentStoreScatterDataProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/SegmentStoreScatterDataProvider.java @@ -12,7 +12,6 @@ package org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -26,6 +25,7 @@ import java.util.function.Predicate; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IGroupingSegmentAspect; import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider; import org.eclipse.tracecompass.internal.analysis.timing.core.Activator; import org.eclipse.tracecompass.internal.tmf.core.model.AbstractTmfTraceDataProvider; @@ -53,13 +53,11 @@ import org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider; import org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel; import org.eclipse.tracecompass.tmf.core.response.ITmfResponse; import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse; -import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; -import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.Iterables; @@ -93,6 +91,8 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide private final BiMap<Long, String> fIdToType = HashBiMap.create(); private final long fTraceId = ENTRY_ID.getAndIncrement(); + private Iterable<IGroupingSegmentAspect> fGroupingAspects; + private static class CheckSegmentType implements Predicate<ISegment> { private final Set<String> fSelectedTypes; @@ -196,9 +196,9 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide /** * Create an instance of {@link SegmentStoreScatterDataProvider} for a given - * analysis ID. Returns a null instance if the ISegmentStoreProvider is null. If - * the provider is an instance of {@link IAnalysisModule}, analysis is also - * scheduled. + * analysis ID. Returns a null instance if the ISegmentStoreProvider is + * null. If the provider is an instance of {@link IAnalysisModule}, analysis + * is also scheduled. * <p> * If the trace has multiple analysis modules with the same secondary ID, * <code>null</code> is returned so the caller can try to make a @@ -213,14 +213,16 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide * @since 4.0 */ public static @Nullable ITmfTreeDataProvider<? extends ITmfTreeDataModel> create(ITmfTrace trace, String secondaryId) { - // The trace can be an experiment, so we need to know if there are multiple analysis modules with the same ID + // The trace can be an experiment, so we need to know if there are multiple + // analysis modules with the same ID Iterable<ISegmentStoreProvider> modules = TmfTraceUtils.getAnalysisModulesOfClass(trace, ISegmentStoreProvider.class); Iterable<ISegmentStoreProvider> filteredModules = Iterables.filter(modules, m -> ((IAnalysisModule) m).getId().equals(secondaryId)); Iterator<ISegmentStoreProvider> iterator = filteredModules.iterator(); if (iterator.hasNext()) { ISegmentStoreProvider module = iterator.next(); if (iterator.hasNext()) { - // More than one module, must be an experiment, return null so the factory can try with individual traces + // More than one module, must be an experiment, return null so the factory can + // try with individual traces return null; } ((IAnalysisModule) module).schedule(); @@ -235,6 +237,7 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide private SegmentStoreScatterDataProvider(ITmfTrace trace, ISegmentStoreProvider provider, String secondaryId) { super(trace); fProvider = provider; + fGroupingAspects = Iterables.filter(provider.getSegmentAspects(), IGroupingSegmentAspect.class); fId = ID + ':' + secondaryId; } @@ -257,7 +260,7 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide long end = filter.getEnd(); final Iterable<ISegment> intersectingElements = Iterables.filter(segStore.getIntersectingElements(start, end), s -> s.getStart() >= start); - Set<String> segmentTypes = new HashSet<>(); + Map<String, INamedSegment> segmentTypes = new HashMap<>(); IAnalysisModule module = (provider instanceof IAnalysisModule) ? (IAnalysisModule) provider : null; boolean complete = module == null ? true : module.isQueryable(filter.getEnd()); @@ -266,20 +269,36 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide if (monitor != null && monitor.isCanceled()) { return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED); } - segmentTypes.add(segment.getName()); + segmentTypes.put(segment.getName(), segment); } Builder<TmfTreeDataModel> nodes = new ImmutableList.Builder<>(); nodes.add(new TmfTreeDataModel(fTraceId, -1, Collections.singletonList(String.valueOf(getTrace().getName())))); - - // There are segments, but no type, probably not named segments, so just add a category - if (segmentTypes.isEmpty() && intersectingElements.iterator().hasNext()) { - long seriesId = getUniqueId(DEFAULT_CATEGORY); - nodes.add(new TmfTreeDataModel(seriesId, fTraceId, Collections.singletonList(DEFAULT_CATEGORY))); - } - for (String seriesName : segmentTypes) { - long seriesId = getUniqueId(seriesName); - nodes.add(new TmfTreeDataModel(seriesId, fTraceId, Collections.singletonList(seriesName))); + Map<IGroupingSegmentAspect, Map<String, Long>> names = new HashMap<>(); + + for (Entry<String, INamedSegment> series : segmentTypes.entrySet()) { + long parentId = fTraceId; + /* + * Create a tree sorting aspects by "Grouping aspect" much like + * counter analyses + */ + for (IGroupingSegmentAspect aspect : fGroupingAspects) { + names.putIfAbsent(aspect, new HashMap<>()); + Map<String, Long> map = names.get(aspect); + if (map == null) { + break; + } + String name = String.valueOf(aspect.resolve(series.getValue())); + Long uniqueId = map.get(name); + if (uniqueId == null) { + uniqueId = getUniqueId(name); + map.put(name, uniqueId); + nodes.add(new TmfTreeDataModel(uniqueId, parentId, name)); + } + parentId = uniqueId; + } + long seriesId = getUniqueId(series.getKey()); + nodes.add(new TmfTreeDataModel(seriesId, parentId, series.getKey())); } return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), nodes.build()), complete ? ITmfResponse.Status.COMPLETED : ITmfResponse.Status.RUNNING, @@ -322,7 +341,8 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide long start = filter.getStart(); long end = filter.getEnd(); - // The types in the tree do not contain the trace name for sake of readability, but + // The types in the tree do not contain the trace name for sake of readability, + // but // the name of the series in XY model should be unique per trace String prefix = getTrace().getName() + '/'; Map<String, Series> types = initTypes(prefix, filter); @@ -350,7 +370,7 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide Series thisSeries = types.get(name); if (thisSeries == null) { // This shouldn't be, log an error and continue - Activator.getInstance().logError("Series " + thisSeries + " should exist"); //$NON-NLS-1$//$NON-NLS-2$ + Activator.getInstance().logError("Series " + thisSeries + " should exist"); //$NON-NLS-1$//$NON-NLS-2$ continue; } @@ -393,7 +413,7 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide if (!predicates.isEmpty()) { // Get the filter external input data - Multimap<@NonNull String, @NonNull String> input = getFilterInput(segment); + Multimap<@NonNull String, @NonNull String> input = ISegmentStoreProvider.getFilterInput(fProvider, segment); // Test each predicates and set the status of the property associated to the // predicate @@ -418,17 +438,6 @@ public class SegmentStoreScatterDataProvider extends AbstractTmfTraceDataProvide } } - private Multimap<String, String> getFilterInput(ISegment segment) { - Multimap<String, String> map = HashMultimap.create(); - for(ISegmentAspect aspect : fProvider.getSegmentAspects()) { - Object resolve = aspect.resolve(segment); - if (resolve != null) { - map.put(aspect.getName(), String.valueOf(resolve)); - } - } - return map; - } - private static class Series { private final long fId; private final String fName; diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java index a8c1d59a3a..0efb5ffc87 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java @@ -74,6 +74,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Collections2; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.Multimap; /** @@ -323,20 +324,20 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView // and model can be updated //FIXME Filtering should be done at the data provider level - Map<@NonNull Integer, @NonNull Predicate<@NonNull Map<@NonNull String, @NonNull String>>> predicates = computeRegexPredicate(); + Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull String>>> predicates = generateRegexPredicate(); Predicate<ISegment> predicate = (segment) -> { if (!predicates.isEmpty()) { // Get the filter external input data - Map<@NonNull String, @NonNull String> input = getFilterInput(segment, provider); + Multimap<@NonNull String, @NonNull String> input = ISegmentStoreProvider.getFilterInput(provider, segment); // Test each predicates and set the status of the property associated to the // predicate boolean activateProperty = false; - for (Map.Entry<Integer, Predicate<Map<String, String>>> mapEntry : predicates.entrySet()) { + for (Map.Entry<Integer, Predicate<Multimap<String, String>>> mapEntry : predicates.entrySet()) { Integer property = Objects.requireNonNull(mapEntry.getKey()); - Predicate<Map<String, String>> value = Objects.requireNonNull(mapEntry.getValue()); - if (property == IFilterProperty.DIMMED | property == IFilterProperty.EXCLUDE) { + Predicate<Multimap<String, String>> value = Objects.requireNonNull(mapEntry.getValue()); + if (property == IFilterProperty.DIMMED || property == IFilterProperty.EXCLUDE) { boolean status = value.test(input); activateProperty |= status; } @@ -368,17 +369,6 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView } } - private static Map<String, String> getFilterInput(ISegment segment, ISegmentStoreProvider provider) { - Map<String, String> map = new HashMap<>(); - for(ISegmentAspect aspect : provider.getSegmentAspects()) { - Object resolve = aspect.resolve(segment); - if (resolve != null) { - map.put(aspect.getName(), String.valueOf(resolve)); - } - } - return map; - } - /** * Compute the predicate for every property regexes * @@ -401,14 +391,11 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView return predicates; } - private static Predicate<@NonNull Map<@NonNull String, @NonNull String>> multiToMapPredicate(@NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull String>> predicate) { - return new Predicate<@NonNull Map<@NonNull String, @NonNull String>> () { - - @Override - public boolean test(@NonNull Map<@NonNull String, @NonNull String> arg0) { - return predicate.test(ImmutableMultimap.copyOf(arg0.entrySet())); - } - + private static Predicate<@NonNull Map<@NonNull String, @NonNull String>> multiToMapPredicate(Predicate<@NonNull Multimap<@NonNull String, @NonNull String>> predicate) { + return map -> { + Builder<@NonNull String, @NonNull String> builder = ImmutableMultimap.builder(); + map.forEach((key, value) -> builder.put(key, value)); + return predicate.test(Objects.requireNonNull(builder.build())); }; } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/scatter/SegmentStoreScatterGraphTooltipProvider.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/scatter/SegmentStoreScatterGraphTooltipProvider.java index 395b11847f..6768deb948 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/scatter/SegmentStoreScatterGraphTooltipProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/scatter/SegmentStoreScatterGraphTooltipProvider.java @@ -38,7 +38,6 @@ public class SegmentStoreScatterGraphTooltipProvider extends TmfClosestDataPoint */ public SegmentStoreScatterGraphTooltipProvider(ITmfChartTimeProvider tmfChartViewer) { super(tmfChartViewer); - register(); } // ------------------------------------------------------------------------ diff --git a/common/org.eclipse.tracecompass.common.core/annotations/com/google/common/collect/Table.eea b/common/org.eclipse.tracecompass.common.core/annotations/com/google/common/collect/Table.eea index 8ad38c7182..183efe5c99 100644 --- a/common/org.eclipse.tracecompass.common.core/annotations/com/google/common/collect/Table.eea +++ b/common/org.eclipse.tracecompass.common.core/annotations/com/google/common/collect/Table.eea @@ -1,4 +1,28 @@ class com/google/common/collect/Table +cellSet + ()Ljava/util/Set<Lcom/google/common/collect/Table$Cell<TR;TC;TV;>;>; + ()L1java/util/Set<Lcom/google/common/collect/Table$Cell<TR;TC;TV;>;>; +column + (TC;)Ljava/util/Map<TR;TV;>; + (TC;)L1java/util/Map<TR;TV;>; +columnKeySet + ()Ljava/util/Set<TC;>; + ()L1java/util/Set<TC;>; +columnMap + ()Ljava/util/Map<TC;Ljava/util/Map<TR;TV;>;>; + ()L1java/util/Map<TC;Ljava/util/Map<TR;TV;>;>; get (Ljava/lang/Object;Ljava/lang/Object;)TV; (Ljava/lang/Object;Ljava/lang/Object;)T0V; +row + (TR;)Ljava/util/Map<TC;TV;>; + (TR;)L1java/util/Map<TC;TV;>; +rowKeySet + ()Ljava/util/Set<TR;>; + ()L1java/util/Set<TR;>; +rowMap + ()Ljava/util/Map<TR;Ljava/util/Map<TC;TV;>;>; + ()L1java/util/Map<TR;Ljava/util/Map<TC;TV;>;>; +values + ()Ljava/util/Collection<TV;>; + ()L1java/util/Collection<TV;>; diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFStreamTest.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFStreamTest.java index e9b3202eee..f5b44b6a89 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFStreamTest.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFStreamTest.java @@ -104,6 +104,19 @@ public class CTFStreamTest { fixture.addEvent(event); } + + /** + * Run the void addEvent(EventDeclaration) method test with the basic huge id'ed event. + * + * @throws ParseException + */ + @Test + public void testAddHugeIDEvent_base() throws ParseException { + EventDeclaration event = new EventDeclaration(); + event.setId(123456789); + fixture.addEvent(event); + } + /** * Run the boolean eventContextIsSet() method test. */ diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceWriterTest.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceWriterTest.java index f91bff28f3..00efd916d4 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceWriterTest.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceWriterTest.java @@ -30,7 +30,7 @@ import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTraceUtils; import org.eclipse.tracecompass.ctf.core.trace.CTFTrace; import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader; import org.eclipse.tracecompass.ctf.core.trace.CTFTraceWriter; -import org.eclipse.tracecompass.internal.ctf.core.trace.Utils; +import org.eclipse.tracecompass.internal.ctf.core.utils.Utils; import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace; import org.junit.BeforeClass; import org.junit.Test; diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/util/SparseListTest.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/util/SparseListTest.java new file mode 100644 index 0000000000..1a9b9c2785 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/util/SparseListTest.java @@ -0,0 +1,537 @@ +/******************************************************************************* + * Copyright (c) 2019 Ericsson + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.tracecompass.ctf.core.tests.util; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.eclipse.tracecompass.internal.ctf.core.utils.SparseList; +import org.junit.Test; + +/** + * Sparse list test + * + * @author Matthew Khouzam + */ +public class SparseListTest { + + /** + * Create a list + * + * @return the list + */ + protected List<String> createList() { + return new SparseList<>(); + } + + /** + * Create a list that copies the data + * + * @param reference + * the source list + * @return a list + */ + protected List<String> createList(List<String> reference) { + return new SparseList<>(reference); + } + + /** + * Test simple building + */ + @Test + public void testSimple() { + List<String> test = createList(); + test.add("Pomme"); + for (int i = 0; i < 99999; i++) { + test.add(null); + } + test.add("Peche"); + for (int i = 0; i < 99999; i++) { + test.add(null); + } + test.add("Poire"); + for (int i = 0; i < 99998; i++) { + test.add(null); + } + test.add("Banane"); + assertEquals(300000, test.size()); + } + + /** + * Test equality of list + */ + @Test + public void testEquality() { + List<String> test = createList(); + test.add("Pomme"); + test.add("Peche"); + test.add("Poire"); + test.add("Banane"); + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", "Banane"); + List<String> badReference = Arrays.asList("Apple", "Peach", "Pear", "Banana"); + List<String> outOfOrderReference = Arrays.asList("Pomme", "Peche", "Banane", "Poire"); + assertEquals(reference, test); + assertNotEquals(badReference, test); + assertNotEquals(outOfOrderReference, test); + assertTrue(test.add(null)); + assertNotEquals(reference, test); + } + + /** + * Test a copy constructor + */ + @Test + public void testCopyConstructor() { + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", "Banane"); + List<String> test = createList(reference); + assertEquals(reference, test); + } + + /** + * Test a copy constructor + */ + @Test + public void testCopyConstructorWithNull() { + List<String> reference = new ArrayList<>(); + reference.add(null); + List<String> test = createList(reference); + assertEquals(reference, test); + } + + /** + * Test with hash collisions + */ + @Test + public void testHashCollision() { + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", "Banane"); + SparseList<String> test = new SparseList<>(); + test.ensureSize(1000000); + test.set(242899, reference.get(0)); + test.set(583202, reference.get(1)); + test.set(703005, reference.get(2)); + test.set(962783, reference.get(3)); + assertArrayEquals(reference.toArray(), test.toArray()); + assertArrayEquals(reference.toArray(new String[4]), test.toArray(new String[4])); + } + + /** + * Test a copy copy copy copy constructor + */ + @Test + public void testRecursiveCopyConstructor() { + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", "Banane"); + List<String> test = createList(createList(createList(createList(reference)))); + assertEquals(reference, test); + } + + /** + * Test a constructor with nulls + */ + @Test + public void testCopyConstructorWithNulls() { + List<String> reference = Arrays.asList("Pomme", null, "Peche", null, "Poire", null, "Banane", null); + List<String> test = createList(reference); + assertEquals(reference, test); + } + + /** + * Test Streams and the spliterator + */ + @Test + public void testStreams() { + List<String> reference = Arrays.asList("Pomme", null, "Peche", null, "Poire", null, "Banane", null); + Optional<String> first = reference.stream().findFirst(); + assertTrue(first.isPresent()); + assertEquals("Pomme", first.get()); + Optional<String> firstNonNull = reference.stream().filter(Objects::nonNull).findFirst(); + assertTrue(firstNonNull.isPresent()); + assertEquals("Pomme", firstNonNull.get()); + assertEquals(4, reference.stream().filter(Objects::isNull).count()); + assertEquals(Arrays.asList("Pomme", null, "Peche", "Poire", "Banane"), reference.stream().distinct().collect(Collectors.toList())); + } + + /** + * Test clear... shouldn't work, but it was easy + */ + @Test + public void testClear() { + List<String> test = createList(); + List<String> reference = Arrays.asList("Pomme", "Peche", null, "Poire", "Banane"); + assertTrue(test.isEmpty()); + test.addAll(reference); + assertEquals(reference, test); + test.clear(); + assertTrue(test.isEmpty()); + } + + /** + * Test is empty + */ + @Test + public void testIsEmpty() { + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", "Banane"); + List<String> test = createList(); + assertTrue(test.isEmpty()); + test.addAll(test); + assertTrue(test.isEmpty()); + test.addAll(reference); + assertFalse(test.isEmpty()); + test = createList(); + assertTrue(test.isEmpty()); + test.add(null); + assertFalse(test.isEmpty()); + } + + /** + * Test contains with null and other + */ + @Test + public void testContains() { + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", "Banane"); + List<String> test = createList(reference); + assertTrue(test.contains("Pomme")); + assertFalse(test.contains(null)); + assertTrue(test.containsAll(Arrays.asList("Peche", "Pomme"))); + assertFalse(test.containsAll(Arrays.asList("Pomme", null, "Peche", null))); + // add a null and re-run + test.add(null); + assertTrue(test.contains("Pomme")); + assertTrue(test.contains(null)); + assertTrue(test.containsAll(Arrays.asList("Peche", "Pomme"))); + assertTrue(test.containsAll(Arrays.asList("Pomme", null, "Peche", null))); + } + + /** + * Test indexOfs + */ + @Test + public void testIndexOf() { + List<String> test = createList(); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("mushroom"); + test.add("mushroom"); + assertEquals(0, test.indexOf("badger")); + assertEquals(-1, test.indexOf("a snake")); + assertEquals(-1, test.indexOf(null)); + assertEquals(-1, test.lastIndexOf(null)); + assertEquals(11, test.lastIndexOf("badger")); + assertTrue(test.contains("badger")); + assertTrue(test.containsAll(Collections.singleton("badger"))); + assertTrue(test.containsAll(Arrays.asList("badger", "mushroom"))); + } + + /** + * Test streams + */ + @Test + public void testStream() { + List<String> test = createList(); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("badger"); + test.add("mushroom"); + test.add("mushroom"); + assertEquals(12, test.parallelStream().filter("badger"::equals).count()); + } + + /** + * Test toArray + */ + @Test + public void testToArray() { + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", "Banane"); + List<String> test = createList(reference); + assertArrayEquals(reference.toArray(), test.toArray()); + assertArrayEquals(reference.toArray(new String[4]), test.toArray(new String[4])); + List<String> referenceWithNulls = Arrays.asList("Pomme", "Peche", "Poire", null, "Banane"); + test = createList(referenceWithNulls); + assertArrayEquals(reference.toArray(), test.toArray()); + assertArrayEquals(reference.toArray(new String[4]), test.toArray(new String[4])); + assertArrayEquals(reference.toArray(new String[4]), test.toArray(new String[1])); + assertArrayEquals(reference.toArray(new String[5]), test.toArray(new String[5])); + try { + assertArrayEquals(reference.toArray(new String[4]), test.toArray(new Long[4])); + fail("Should not get here"); + } catch (ArrayStoreException e) { + // correct flow + } + } + + /** + * Test toString + */ + @Test + public void testToString() { + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", null, "Banane"); + List<String> test = createList(reference); + assertEquals("[0:Pomme, 1:Peche, 2:Poire, 4:Banane]", test.toString()); + } + + /** + * Test the set operation + */ + @Test + public void testSet() { + List<String> reference = Arrays.asList("Pomme", "Peche", "Poire", "Banane"); + List<String> test = createList(reference); + assertEquals(reference, test); + test.set(0, "pomme"); + assertNotEquals(reference, test); + try { + test.set(-1, "pomme"); + fail("Should not get here"); + } catch (IndexOutOfBoundsException e) { + // correct flow + } + try { + test.set(5, "pomme"); + fail("Should not get here"); + } catch (IndexOutOfBoundsException e) { + // correct flow + } + } + + /** + * Test the list iterator + */ + @Test + public void testListIterator() { + testListIterator(createList(Arrays.asList("Hola", "yo", "quiero", "un", "UNSUPPORTEDOPERATIONEXCEPTION!"))); + } + + /** + * Test the list iterator out of order + */ + @Test + public void testListIteratorOutOfOrder() { + SparseList<String> list = new SparseList<>(); + list.ensureSize(5); + list.set(4, "UNSUPPORTEDOPERATIONEXCEPTION!"); + list.set(2, "quiero"); + list.set(1, "yo"); + list.set(0, "Hola"); + list.set(3, "un"); + testListIterator(list); + } + + private static void testListIterator(List<String> test) { + ListIterator<String> iterator = test.listIterator(0); + assertTrue(iterator.hasNext()); + assertFalse(iterator.hasPrevious()); + try { + iterator.previous(); + fail("Should not get here"); + } catch (NoSuchElementException e) { + // correct flow + } + assertEquals("Hola", iterator.next()); + assertEquals("yo", iterator.next()); + assertEquals("yo", iterator.previous()); + assertEquals("Hola", iterator.previous()); + try { + iterator.previous(); + fail("Should not get here"); + } catch (NoSuchElementException e) { + // correct flow + } + assertEquals("Hola", iterator.next()); + assertEquals("yo", iterator.next()); + assertEquals("quiero", iterator.next()); + assertEquals("un", iterator.next()); + assertEquals("UNSUPPORTEDOPERATIONEXCEPTION!", iterator.next()); + try { + iterator.next(); + fail("Should not get here"); + } catch (NoSuchElementException e) { + // correct flow + } + assertEquals("UNSUPPORTEDOPERATIONEXCEPTION!", iterator.previous()); + assertEquals(3, iterator.previousIndex()); + assertEquals(4, iterator.nextIndex()); + try { + iterator.remove(); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + iterator.set("hej"); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + iterator.add("hi"); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + } + + /** + * Test a list iterator with nulls + */ + @Test + public void testListIteratorWithNull() { + List<String> list = createList(Arrays.asList("Hello", null, "world")); + ListIterator<String> iterator = list.listIterator(); + assertEquals("Hello", iterator.next()); + assertEquals(null, iterator.next()); + assertEquals("world", iterator.next()); + assertEquals("world", iterator.previous()); + assertEquals(null, iterator.previous()); + assertEquals("Hello", iterator.previous()); + iterator = list.listIterator(0); + assertEquals("Hello", iterator.next()); + assertEquals(null, iterator.next()); + assertEquals("world", iterator.next()); + assertEquals("world", iterator.previous()); + assertEquals(null, iterator.previous()); + assertEquals("Hello", iterator.previous()); + iterator = list.listIterator(1); + assertEquals("Hello", iterator.previous()); + assertEquals("Hello", iterator.next()); + assertEquals(null, iterator.next()); + assertEquals("world", iterator.next()); + assertEquals("world", iterator.previous()); + assertEquals(null, iterator.previous()); + assertEquals("Hello", iterator.previous()); + iterator = list.listIterator(2); + assertEquals(null, iterator.previous()); + assertEquals("Hello", iterator.previous()); + assertEquals("Hello", iterator.next()); + assertEquals(null, iterator.next()); + assertEquals("world", iterator.next()); + assertEquals("world", iterator.previous()); + assertEquals(null, iterator.previous()); + assertEquals("Hello", iterator.previous()); + } + + /** + * Test setting the values our of order + */ + @Test + public void testUnorderedSet() { + String value = "badger"; + List<String> test = createList(); + ((SparseList<String>) test).ensureSize(5); + test.set(4, value); + test.set(2, value); + assertEquals(2, test.indexOf(value)); + assertEquals(4, test.lastIndexOf(value)); + assertEquals(0, test.indexOf(null)); + assertEquals(3, test.lastIndexOf(null)); + assertEquals(-1, test.indexOf("mushroom")); + assertEquals(-1, test.lastIndexOf("mushroom")); + assertNull(test.get(0)); + assertNull(test.get(1)); + assertEquals(value, test.get(2)); + assertNull(test.get(3)); + assertEquals(value, test.get(4)); + test.set(0, value); + assertEquals(1, test.indexOf(null)); + } + + /** + * Reminds people to update tests if they add these features. + */ + @Test + public void testUnsupporteds() { + List<String> test = createList(); + try { + test.addAll(0, Collections.emptyList()); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + test.add(0, null); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + test.remove(0); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + test.subList(0, 0); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + test.remove("que?"); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + test.removeAll(Collections.singletonList("que?")); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + test.retainAll(Arrays.asList("que", "pasa?")); + fail("Should not get here"); + } catch (UnsupportedOperationException e) { + // correct flow + } + try { + test.get(-1); + fail("Should not get here"); + } catch (IndexOutOfBoundsException e) { + // correct flow + } + try { + test.get(test.size()); + fail("Should not get here"); + } catch (IndexOutOfBoundsException e) { + // correct flow + } + } +} diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/UtilsTest.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/util/UtilsTest.java index c98b72b018..8428c6c9f6 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/UtilsTest.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/util/UtilsTest.java @@ -9,7 +9,7 @@ * Matthew Khouzam - Initial API and implementation *******************************************************************************/ -package org.eclipse.tracecompass.ctf.core.tests.trace; +package org.eclipse.tracecompass.ctf.core.tests.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull; import java.util.UUID; import org.eclipse.tracecompass.ctf.core.CTFException; -import org.eclipse.tracecompass.internal.ctf.core.trace.Utils; +import org.eclipse.tracecompass.internal.ctf.core.utils.Utils; import org.junit.Test; /** diff --git a/ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF b/ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF index 142612a8b9..e14b7b4a8c 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF +++ b/ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF @@ -20,7 +20,7 @@ Export-Package: org.eclipse.tracecompass.ctf.core, org.eclipse.tracecompass.ctf.core.event.types, org.eclipse.tracecompass.ctf.core.trace, org.eclipse.tracecompass.internal.ctf.core;x-friends:="org.eclipse.tracecompass.ctf.core.tests", - org.eclipse.tracecompass.internal.ctf.core.event;x-friends:="org.eclipse.tracecompass.ctf.core.tests", + org.eclipse.tracecompass.internal.ctf.core.event;x-friends:="org.eclipse.tracecompass.ctf.core.tests,org.eclipse.tracecompass.tmf.ctf.core.tests", org.eclipse.tracecompass.internal.ctf.core.event.metadata;x-friends:="org.eclipse.tracecompass.ctf.core.tests", org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl;x-friends:="org.eclipse.tracecompass.ctf.core.tests", org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.callsite;x-internal:=true, @@ -36,7 +36,8 @@ Export-Package: org.eclipse.tracecompass.ctf.core, org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.variant;x-friends:="org.eclipse.tracecompass.ctf.core.tests", org.eclipse.tracecompass.internal.ctf.core.event.types;x-friends:="org.eclipse.tracecompass.ctf.core.tests,org.eclipse.tracecompass.tmf.ctf.core,org.eclipse.tracecompass.tmf.ctf.core.tests", org.eclipse.tracecompass.internal.ctf.core.event.types.composite;x-friends:="org.eclipse.tracecompass.ctf.core.tests", - org.eclipse.tracecompass.internal.ctf.core.trace;x-friends:="org.eclipse.tracecompass.ctf.core.tests" + org.eclipse.tracecompass.internal.ctf.core.trace;x-friends:="org.eclipse.tracecompass.ctf.core.tests", + org.eclipse.tracecompass.internal.ctf.core.utils;x-friends:="org.eclipse.tracecompass.ctf.core.tests" Import-Package: com.google.common.base, com.google.common.collect, org.antlr.runtime;version="3.2.0", diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java index c87b075d45..9144316f47 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java @@ -713,8 +713,7 @@ public final class BitBuffer { } /** - * - * Sets the position in the buffer. + * Gets the position in the buffer, in bits. * * @return order The position of the buffer. */ diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java index 220881f374..128342df13 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java @@ -37,7 +37,7 @@ import org.eclipse.tracecompass.internal.ctf.core.Activator; import org.eclipse.tracecompass.internal.ctf.core.SafeMappedByteBuffer; import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndex; import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndexEntry; -import org.eclipse.tracecompass.internal.ctf.core.trace.Utils; +import org.eclipse.tracecompass.internal.ctf.core.utils.Utils; /** * <b><u>StreamInput</u></b> diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java index b4eb825e75..5f124c630e 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java @@ -56,7 +56,7 @@ import org.eclipse.tracecompass.internal.ctf.core.SafeMappedByteBuffer; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.MetadataStrings; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException; import org.eclipse.tracecompass.internal.ctf.core.trace.CTFStream; -import org.eclipse.tracecompass.internal.ctf.core.trace.Utils; +import org.eclipse.tracecompass.internal.ctf.core.utils.Utils; import com.google.common.collect.ImmutableMap; diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/Metadata.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/Metadata.java index e290cfd81e..c1ae32d98c 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/Metadata.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/Metadata.java @@ -45,7 +45,7 @@ import org.eclipse.tracecompass.ctf.parser.CTFParser.parse_return; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.CtfAntlrException; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.IOStructGen; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException; -import org.eclipse.tracecompass.internal.ctf.core.trace.Utils; +import org.eclipse.tracecompass.internal.ctf.core.utils.Utils; /** * The CTF trace metadata TSDL file diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java index 14c1791f80..8862ee42b9 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java @@ -114,7 +114,8 @@ public class SequenceDeclaration extends CompoundDeclaration { } long length = lengthDefinition.getValue(); - if ((length > Integer.MAX_VALUE) || (!input.canRead((int) length * fElemType.getMaximumSize()))) { + long maxBits = length * fElemType.getMaximumSize(); + if ((length > Integer.MAX_VALUE) || (maxBits > Integer.MAX_VALUE) || (!input.canRead((int) maxBits))) { throw new CTFException("Sequence length too long " + length); //$NON-NLS-1$ } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/CTFStream.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/CTFStream.java index e4988c22fd..f2c819952a 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/CTFStream.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/CTFStream.java @@ -30,6 +30,7 @@ import org.eclipse.tracecompass.ctf.core.trace.CTFTrace; import org.eclipse.tracecompass.ctf.core.trace.ICTFStream; import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException; +import org.eclipse.tracecompass.internal.ctf.core.utils.SparseList; /** * <b><u>Stream</u></b> @@ -62,7 +63,7 @@ public class CTFStream implements ICTFStream { /** * Maps event ids to events */ - private final ArrayList<@Nullable IEventDeclaration> fEvents = new ArrayList<>(); + private List<@Nullable IEventDeclaration> fEvents = new ArrayList<>(); private boolean fEventUnsetId = false; private boolean fStreamIdSet = false; @@ -252,7 +253,7 @@ public class CTFStream implements ICTFStream { if (fEvents.size() > id && fEvents.get(id) != null) { throw new ParseException("Event id already exists"); //$NON-NLS-1$ } - ensureSize(fEvents, id); + ensureSize(id); /* Put the event in the list */ fEvents.set(id, event); } @@ -279,7 +280,7 @@ public class CTFStream implements ICTFStream { for (IEventDeclaration event : events) { if (event != null) { int index = event.getId().intValue(); - ensureSize(fEvents, index); + ensureSize(index); if (fEvents.get(index) != null) { throw new CTFException("Both lists have an event defined at position " + index); //$NON-NLS-1$ } @@ -288,10 +289,22 @@ public class CTFStream implements ICTFStream { } } - private static void ensureSize(ArrayList<@Nullable ? extends Object> list, int index) { - list.ensureCapacity(index); - while (list.size() <= index) { - list.add(null); + private void ensureSize(int index) { + List<@Nullable IEventDeclaration> list = fEvents; + if (list instanceof ArrayList) { + if (index > 50000) { + SparseList<@Nullable IEventDeclaration> sparseList = new SparseList<>(fEvents); + sparseList.ensureSize(index + 1); + fEvents = sparseList; + return; + } + ((ArrayList<@Nullable IEventDeclaration>) list).ensureCapacity(index); + while (list.size() <= index) { + list.add(null); + } + } else if (list instanceof SparseList) { + SparseList sparseList = (SparseList) list; + sparseList.ensureSize(index + 1); } } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java index ea3be0930c..7f0edd47f6 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java @@ -19,6 +19,7 @@ import java.util.Comparator; import org.eclipse.tracecompass.ctf.core.event.IEventDefinition; import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader; +import org.eclipse.tracecompass.internal.ctf.core.utils.Utils; /** * <b><u>StreamInputReaderTimestampComparator</u></b> diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/GenericReadOnlyListIterator.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/GenericReadOnlyListIterator.java new file mode 100644 index 0000000000..d7761650aa --- /dev/null +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/GenericReadOnlyListIterator.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2019 Ericsson + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.tracecompass.internal.ctf.core.utils; + +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +/** + * Generic Read only List Iterator + * + * @author Matthew Khouzam + * + * @param <E> + * the element type + */ +final class GenericReadOnlyListIterator<E> implements ListIterator<E> { + private int fCursor; + private final List<E> fList; + + /** + * Constructor + * + * @param list + * the list + * @param start + * the first element to iterate on + */ + public GenericReadOnlyListIterator(List<E> list, int start) { + fList = list; + fCursor = start - 1; + } + + @Override + public boolean hasNext() { + return nextIndex() < fList.size(); + } + + @Override + public E next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + E next = fList.get(nextIndex()); + fCursor++; + return next; + } + + @Override + public boolean hasPrevious() { + return previousIndex() >= 0; + } + + @Override + public E previous() { + if (!hasPrevious()) { + throw new NoSuchElementException(); + } + E prev = fList.get(previousIndex()); + fCursor--; + return prev; + } + + @Override + public int nextIndex() { + return fCursor + 1; + } + + @Override + public int previousIndex() { + return fCursor; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public void set(E e) { + throw new UnsupportedOperationException(); + } + + @Override + public void add(E e) { + throw new UnsupportedOperationException(); + } +}
\ No newline at end of file diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/SparseList.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/SparseList.java new file mode 100644 index 0000000000..0b6b0cb5a2 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/SparseList.java @@ -0,0 +1,353 @@ +/******************************************************************************* + * Copyright (c) 2019 Ericsson + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.tracecompass.internal.ctf.core.utils; + +import java.lang.reflect.Array; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Spliterator; +import java.util.Spliterators; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; + +/** + * <p> + * Sparse list, a list optimized for when most of the data is <code>null</code>. + * Nulls will increment the size of the SparseList but they are not stored + * internally. + * </p> + * <p> + * Note: this iterates in the list order. + * </p> + * This implementation does not support: + * <ul> + * <li>{@link #add(int, Object)}</li> + * <li>{@link #addAll(int, Collection)}</li> + * <li>{@link #remove(int)}</li> + * <li>{@link #remove(Object)}</li> + * <li>{@link #removeAll(Collection)}</li> + * <li>{@link #subList(int, int)}</li> + * </ul> + * </p> + * <p> + * An efficient shift operation for bulk moving elements in a list would be + * needed in order to implement these features. + * </p> + * TODO: Keep an eye out for a better datastructure... SparseList is intended as + * a stop-gap fix. It is fine, but if it can be replaced by an externally + * maintained datastructure, that would be better. + * + * @author Matthew Khouzam + * @param <E> + * the element type + */ +public class SparseList<E> implements List<E> { + + /** + * A backing map used to store the non-null elements + */ + private final Map<Integer, @NonNull E> fInnerElements = new HashMap<>(); + /** + * The list size: map size + number of nulls + */ + private int fSize = 0; + + /** + * Copy constructor + * + * @param events + * list of events + */ + public SparseList(List<E> events) { + ensureSize(events.size()); + for (int i = 0; i < events.size(); i++) { + E element = events.get(i); + if (element != null) { + set(i, element); + } + } + } + + /** + * default constructor + */ + public SparseList() { + // Do nothing + } + + @Override + public int size() { + return fSize; + } + + @Override + public boolean isEmpty() { + return fSize == 0; + } + + @Override + public boolean contains(Object o) { + return o == null ? size() > fInnerElements.size() : fInnerElements.containsValue(o); + } + + @Override + public Iterator<E> iterator() { + return new GenericReadOnlyListIterator<>(this, 0); + } + + /** + * Break in contract with {@link List#toArray()} implementation. This + * returns an list-ordered array of size N where N is the number of non-null + * elements. This is a design concession to avoid out of memory errors with + * the sparse list, since this list should only be used when memory + * footprint is important. + * + * The returned array will be "safe" in that no references to it are + * maintained by this list. (In other words, this method must allocate a new + * array even if this list is backed by an array). The caller is thus free + * to modify the returned array. + * + * @return an array containing all of the non-null elements in this list in + * proper sequence + */ + @Override + public Object[] toArray() { + int size = fInnerElements.size(); + Object[] retVal = new Object[size]; + Iterator<E> iterator = iterator(); + for (int i = 0; i < size; i++) { + Object next = null; + while (iterator.hasNext() && next == null) { + next = iterator.next(); + } + retVal[i] = next; + } + return retVal; + } + + /** + * Break in contract with {@link List#toArray(Object[])} implementation. + * + * Returns an array containing all of the <strong>non-null</strong> elements + * in this list in proper sequence (from first to last element); the runtime + * type of the returned array is that of the specified array. If the list + * fits in the specified array, it is returned therein. Otherwise, only the + * first n elements of the list are returned. + * + * This is a design concession to avoid out of memory errors with the sparse + * list, since this list should only be used when memory footprint is + * important. + * + * @param newArray + * the array to return + * @return newArray, filled with values. + */ + @SuppressWarnings("unchecked") + @Override + public <T> T[] toArray(T[] newArray) { + + Class<?> componentType = newArray.getClass().getComponentType(); + T[] returnArray = newArray; + int size = fInnerElements.size(); + if (returnArray.length < size) { + returnArray = (T[]) Array.newInstance(componentType, size); + } + for (int i = size; i < returnArray.length; i++) { + returnArray[i] = null; + } + Iterator<E> iterator = iterator(); + for (int i = 0; i < size; i++) { + @Nullable E next = null; + while (iterator.hasNext() && next == null) { + next = iterator.next(); + } + returnArray[i] = (T) next; + } + return returnArray; + } + + @Override + public boolean add(E e) { + if (e != null) { + fInnerElements.put(fSize, e); + } + fSize++; + return true; + } + + @Override + public boolean containsAll(Collection<?> c) { + Collection<?> nonNullCollection = c; + if (nonNullCollection.contains(null)) { + if (!contains(null)) { + return false; + } + nonNullCollection = c.stream().filter(Objects::nonNull).collect(Collectors.toList()); + } + return fInnerElements.values().containsAll(nonNullCollection); + } + + @Override + public boolean addAll(Collection<? extends E> c) { + int key = fSize; + fSize += c.size(); + for (E event : c) { + set(key, event); + key++; + } + return true; + } + + @Override + public E get(int index) { + if (index < 0 || index >= size()) { + throw new IndexOutOfBoundsException("Tried to access index " + index + " Sparse list size " + fSize); //$NON-NLS-1$ //$NON-NLS-2$ + } + return fInnerElements.get(index); + } + + @Override + public E set(int index, E element) { + if (index < 0 || index >= size()) { + throw new IndexOutOfBoundsException("Tried to add to index " + index + " Sparse list size " + fSize); //$NON-NLS-1$ //$NON-NLS-2$ + } + if (element != null) { + return fInnerElements.put(index, element); + } + return fInnerElements.remove(index); + } + + @Override + public int indexOf(Object o) { + if (o == null && contains(null)) { + for (int i = 0; i < size(); i++) { + if (!fInnerElements.containsKey(i)) { + return i; + } + } + } + int first = Integer.MAX_VALUE; + for (Entry<Integer, E> entry : fInnerElements.entrySet()) { + if (Objects.equals(entry.getValue(), o)) { + first = Math.min(entry.getKey(), first); + } + } + return first == Integer.MAX_VALUE ? -1 : first; + } + + @Override + public int lastIndexOf(Object o) { + int last = -1; + if (o == null && contains(null)) { + for (int i = size() - 1; i >= 0; i--) { + if (!fInnerElements.containsKey(i)) { + return i; + } + } + } + for (Entry<Integer, E> entry : fInnerElements.entrySet()) { + if (Objects.equals(entry.getValue(), o)) { + last = Math.max(last, entry.getKey()); + } + } + return last; + } + + @Override + public void clear() { + fInnerElements.clear(); + fSize = 0; + } + + @Override + public Spliterator<E> spliterator() { + return Spliterators.spliterator(iterator(), fSize, Spliterator.ORDERED); + } + + @Override + public ListIterator<E> listIterator() { + return new GenericReadOnlyListIterator<>(this, 0); + } + + @Override + public ListIterator<E> listIterator(int index) { + return new GenericReadOnlyListIterator<>(this, index); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (int i = 0; i < size(); i++) { + E element = get(i); + if (element != null) { + sb.append(i).append(':').append(String.valueOf(element)); + + if (i < size() - 1) { + sb.append(',').append(' '); + } + } + } + sb.append(']'); + return sb.toString(); + } + + /** + * resize the list + * + * @param requestedSize + * the new size + */ + public void ensureSize(int requestedSize) { + fSize = Math.max(fSize, requestedSize); + } + + @Override + public void add(int index, E element) { + throw new UnsupportedOperationException("No add(int, E) in " + this.getClass().getName()); //$NON-NLS-1$ + } + + @Override + public E remove(int index) { + throw new UnsupportedOperationException("No remove(int) in " + this.getClass().getName()); //$NON-NLS-1$ + } + + @Override + public boolean remove(Object o) { + throw new UnsupportedOperationException("No remove(Object) in " + this.getClass().getName()); //$NON-NLS-1$ + } + + @Override + public boolean addAll(int index, Collection<? extends E> c) { + throw new UnsupportedOperationException("No addAll(int, Collection<? extends E>) in " + this.getClass().getName()); //$NON-NLS-1$ + } + + @Override + public boolean removeAll(Collection<?> c) { + throw new UnsupportedOperationException("No removeAll(Collection<?>) in " + this.getClass().getName()); //$NON-NLS-1$ + } + + @Override + public boolean retainAll(Collection<?> c) { + throw new UnsupportedOperationException("No retainAll(Collection<?> in " + this.getClass().getName()); //$NON-NLS-1$ + } + + @Override + public @NonNull List<E> subList(int fromIndex, int toIndex) { + throw new UnsupportedOperationException("No subList(int, int) in " + this.getClass().getName()); //$NON-NLS-1$ + } +}
\ No newline at end of file diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/Utils.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/Utils.java index 639225c114..bfdceda6e7 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/Utils.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/utils/Utils.java @@ -10,7 +10,7 @@ * Contributors: Simon Marchi - Initial API and implementation *******************************************************************************/ -package org.eclipse.tracecompass.internal.ctf.core.trace; +package org.eclipse.tracecompass.internal.ctf.core.utils; import java.util.UUID; diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfCpuAspectTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfCpuAspectTest.java new file mode 100644 index 0000000000..2b56196257 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfCpuAspectTest.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2019 Ericsson + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.tracecompass.tmf.ctf.core.tests.event; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.tracecompass.ctf.core.CTFException; +import org.eclipse.tracecompass.ctf.core.event.IEventDefinition; +import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer; +import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration; +import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration; +import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition; +import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration; +import org.eclipse.tracecompass.internal.ctf.core.event.EventDefinition; +import org.eclipse.tracecompass.tmf.core.event.TmfEvent; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventFactory; +import org.eclipse.tracecompass.tmf.ctf.core.event.aspect.CtfCpuAspect; +import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Test the CPU resolution aspect on a ctf trace. + * + * @author Matthew Khoumzam + */ +public class CtfTmfCpuAspectTest { + + private static final @NonNull String ROOT = "root"; + + private List<@NonNull IEventDefinition> fEvents = new ArrayList<>(); + + private CtfTmfTrace fTrace; + + /** + * Create 3 event definitions and a trace, the event definitions should + * stress the CPU aspect. + * + * @throws CTFException + * Won't happen, if the buffer isn't big enough throw an + * exception + */ + @Before + public void setUp() throws CTFException { + + fTrace = new CtfTmfTrace(); + int capacity = 2048; + ByteBuffer bb = ByteBuffer.allocateDirect(capacity); + + StructDeclaration sDec = new StructDeclaration(1l); + IntegerDeclaration intDec = IntegerDeclaration.INT_8_DECL; + + sDec.addField("cpu_id", intDec); + sDec.addField("CpuId", intDec); + /* Set cpu_id = 2 */ + bb.put((byte) 2); + /* Set CpuId = 3 */ + bb.put((byte) 3); + StructDefinition def = sDec.createDefinition(null, ROOT, new BitBuffer(bb)); + EventDeclaration dec = new EventDeclaration(); + dec.setName("hi"); + /* + * CPU in the stream == undefined cpu, has a cpu_id field set to 2, + * resolve to 2 + */ + fEvents.add(new EventDefinition(dec, IEventDefinition.UNKNOWN_CPU, 0, null, null, null, null, def, null)); + /* + * CPU in the stream == 3, has a cpu_id field set to 2, stream take + * priority, resolve to 3 + */ + fEvents.add(new EventDefinition(dec, 3, 0, null, null, null, null, def, null)); + /* + * CPU in the stream == undefined cpu, has a context with cpu_id, + * unsupported, resolves to null + */ + fEvents.add(new EventDefinition(dec, IEventDefinition.UNKNOWN_CPU, 0, null, null, null, def, null, null)); + /* CPU in the stream == undefined cpu, has a no fields */ + fEvents.add(new EventDefinition(dec, IEventDefinition.UNKNOWN_CPU, 0, null, null, null, null, null, null)); + /* CPU in the stream == 6, has a no fields */ + fEvents.add(new EventDefinition(dec, 6, 0, null, null, null, null, null, null)); + } + + /** + * Cleanup + */ + @After + public void dispose() { + fTrace.dispose(); + } + + /** + * Test the cpu aspect + */ + @Test + public void test() { + CtfCpuAspect fixture = new CtfCpuAspect(); + CtfTmfTrace trace = fTrace; + assertNotNull(trace); + CtfTmfEventFactory fabrica = CtfTmfEventFactory.instance(); + + /* + * Evaluate field, no stream + */ + CtfTmfEvent e = fabrica.createEvent(trace, fEvents.get(0), ""); + assertEquals(Integer.valueOf(2), fixture.resolve(e)); + + /* + * Evaluate stream and field + */ + e = fabrica.createEvent(trace, fEvents.get(1), ""); + assertEquals(Integer.valueOf(3), fixture.resolve(e)); + + /* + * Evaluate context + */ + e = fabrica.createEvent(trace, fEvents.get(2), ""); + assertNull(fixture.resolve(e)); + + /* + * Evaluate an empty event + */ + e = fabrica.createEvent(trace, fEvents.get(3), ""); + assertNull(fixture.resolve(e)); + + /* + * Evaluate stream and no field, default LTTng behaviour + */ + e = fabrica.createEvent(trace, fEvents.get(4), ""); + assertEquals(Integer.valueOf(6), fixture.resolve(e)); + + /* + * Evaluate non-ctf event + */ + assertNull(fixture.resolve(new TmfEvent(trace, 0, TmfTimestamp.BIG_BANG, null, null))); + } +} diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerUtilityTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerUtilityTest.java index 6f3df085c2..fec074a3d4 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerUtilityTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerUtilityTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2017 EfficiOS Inc., Alexandre Montplaisir + * Copyright (c) 2016, 2019 EfficiOS Inc., Alexandre Montplaisir and others * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -67,16 +67,13 @@ public class TmfTraceManagerUtilityTest { */ @Test public void testTemporaryDirPath() throws URISyntaxException { - String basePath = TmfTraceManager.getTemporaryDirPath(); - assertTrue(basePath.endsWith(TEMP_DIR_NAME)); + String tempDirPath = TmfTraceManager.getTemporaryDirPath(); + assertTrue(tempDirPath.endsWith(TEMP_DIR_NAME)); String property = System.getProperty("osgi.instance.area"); //$NON-NLS-1$ File dir = URIUtil.toFile(URIUtil.fromString(property)); - String propertyToTest = dir.getAbsolutePath(); - if (property != null) { - basePath = basePath.substring(0, basePath.length() - TEMP_DIR_NAME.length() - 1); - assertTrue(propertyToTest.contains(basePath)); - } + String basePath = dir.getAbsolutePath(); + assertTrue(tempDirPath.startsWith(basePath)); } /** @@ -86,10 +83,10 @@ public class TmfTraceManagerUtilityTest { public void testSupplementaryFileDir() { final ITmfTrace trace = fTrace; assertNotNull(trace); - String name1 = trace.getName(); - String basePath = TmfTraceManager.getTemporaryDirPath() + File.separator; + String tracePath = trace.getPath(); + String tempDirPath = TmfTraceManager.getTemporaryDirPath(); - String expected = basePath + name1 + File.separator; + String expected = Paths.get(tempDirPath, tracePath).toString() + File.separator; assertEquals(expected, TmfTraceManager.getSupplementaryFileDir(trace)); } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/Activator.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/Activator.java index 634273687e..4b7f025354 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/Activator.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/Activator.java @@ -46,6 +46,7 @@ public class Activator extends Plugin { * The constructor */ public Activator() { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/aspect/CtfCpuAspect.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/aspect/CtfCpuAspect.java index 2dfa277f5a..0ec22afc5f 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/aspect/CtfCpuAspect.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/aspect/CtfCpuAspect.java @@ -12,23 +12,40 @@ package org.eclipse.tracecompass.tmf.ctf.core.event.aspect; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.tracecompass.ctf.core.event.IEventDefinition; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; +import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect; import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; /** - * "CPU" event aspect for CTF traces. + * "CPU" event aspect for CTF traces. Resolves cpu_id in stream first, event + * fields second. * * @author Alexandre Montplaisir */ public class CtfCpuAspect extends TmfCpuAspect { + /** + * Refered in the CTF spec + */ + private static final @NonNull String CPU_ID = "cpu_id"; //$NON-NLS-1$ + @Override public Integer resolve(ITmfEvent event) { if (!(event instanceof CtfTmfEvent)) { return null; } int cpu = ((CtfTmfEvent) event).getCPU(); + if (cpu == IEventDefinition.UNKNOWN_CPU) { + ITmfEventField content = event.getContent(); + Long fieldValue = null; + if (content != null) { + fieldValue = content.getFieldValue(Long.class, CPU_ID); + } + return fieldValue == null ? null : fieldValue.intValue(); + } return cpu; } } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/trim/CtfTmfExperimentTrimmingTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/trim/CtfTmfExperimentTrimmingTest.java index d8eb618ae3..b006ec53e4 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/trim/CtfTmfExperimentTrimmingTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/trim/CtfTmfExperimentTrimmingTest.java @@ -45,7 +45,6 @@ import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement; import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils; -import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -183,17 +182,6 @@ public class CtfTmfExperimentTrimmingTest { } /** - * Test teardown - */ - @After - public void tearDown() { - fNewExperiment = null; - fOriginalExperiment = null; - fBot.closeAllEditors(); - SWTBotUtils.clearTracesFolderUI(fBot, PROJECT_NAME); - } - - /** * Get the range at which we should start cutting the trace. It should be * roughly 1/4 into the trace to 1/2 into the trace. */ diff --git a/doc/README b/doc/README index 7c39c9393a..f587233ba1 100644 --- a/doc/README +++ b/doc/README @@ -1,18 +1,13 @@ This describes how to build the documentation found in the org.eclipse.tracecompass.*.doc.* plugins. +To build doc plugins use maven command: mvn clean install -Your Eclipse environment first needs to have the "Mylyn Wikitext" plugin -installed. It can be found in the default Eclipse repository, under -"Collaboration". +To build doc plugins from within Eclipse you need to install m2e. -Once that is installed, you should be able to use the manual Eclipse builder to -generate the doc : select the and individual doc plugin and choose, in the -top-menu, "Project -> Build Project". - -It uses the build.xml Ant script, but it's recommended to run it from within -Eclipse, since the builder will pass some environment variables that the script -needs. +To edit the mediawiki text, your Eclipse environment first needs to have the +"Mylyn Wikitext" plugin installed. It can be found in the default Eclipse repository, +under "Collaboration". You might get a warning from build.properties because of a missing file. This file gets generated with the rest of the doc, so once you have run these steps diff --git a/doc/org.eclipse.tracecompass.doc.dev/.externalToolBuilders/Trace Compass Developer Guide Builder.launch b/doc/org.eclipse.tracecompass.doc.dev/.externalToolBuilders/Trace Compass Developer Guide Builder.launch deleted file mode 100644 index ee9b121b8f..0000000000 --- a/doc/org.eclipse.tracecompass.doc.dev/.externalToolBuilders/Trace Compass Developer Guide Builder.launch +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> -<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/> -<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="build,build.index,"/> -<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> -<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> -<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/org.eclipse.tracecompass.doc.dev" type="4"/> </resources>}"/> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/org.eclipse.tracecompass.doc.dev/build.xml"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.tracecompass.doc.dev"/> -<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.tracecompass.doc.dev/build.xml}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,clean"/> -<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> -<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/> -</launchConfiguration> diff --git a/doc/org.eclipse.tracecompass.doc.dev/.project b/doc/org.eclipse.tracecompass.doc.dev/.project index 86f69dbe85..62f98aca10 100644 --- a/doc/org.eclipse.tracecompass.doc.dev/.project +++ b/doc/org.eclipse.tracecompass.doc.dev/.project @@ -6,20 +6,6 @@ </projects> <buildSpec> <buildCommand> - <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> - <triggers>clean,full,incremental,</triggers> - <arguments> - <dictionary> - <key>LaunchConfigHandle</key> - <value><project>/.externalToolBuilders/Trace Compass Developer Guide Builder.launch</value> - </dictionary> - <dictionary> - <key>incclean</key> - <value>true</value> - </dictionary> - </arguments> - </buildCommand> - <buildCommand> <name>org.eclipse.pde.ManifestBuilder</name> <arguments> </arguments> @@ -32,6 +18,5 @@ </buildSpec> <natures> <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.mylyn.wikitext.ui.wikiTextNature</nature> </natures> </projectDescription> diff --git a/doc/org.eclipse.tracecompass.doc.dev/build.properties b/doc/org.eclipse.tracecompass.doc.dev/build.properties index 36adb1b073..d12d9d3751 100644 --- a/doc/org.eclipse.tracecompass.doc.dev/build.properties +++ b/doc/org.eclipse.tracecompass.doc.dev/build.properties @@ -17,8 +17,5 @@ bin.includes = plugin.xml,\ book.css,\ doc/,\ index/ -jars.extra.classpath = platform:/plugin/org.eclipse.mylyn.wikitext.core,\ - platform:/plugin/org.eclipse.mylyn.wikitext.core.ant,\ - platform:/plugin/org.eclipse.mylyn.wikitext.mediawiki.core src.includes = about.html diff --git a/doc/org.eclipse.tracecompass.doc.dev/build.xml b/doc/org.eclipse.tracecompass.doc.dev/build.xml index d07ccc8f64..6e058e2638 100644 --- a/doc/org.eclipse.tracecompass.doc.dev/build.xml +++ b/doc/org.eclipse.tracecompass.doc.dev/build.xml @@ -6,18 +6,7 @@ <property name="document.title" value="Trace Compass Developer Guide" /> - <path id="wikitext.tasks.classpath"> - <!-- Search in the local Eclipse plugins directory for the Wikitext plugin --> - <fileset dir="${osgi.syspath}" erroronmissingdir="false"> - <include name="org.eclipse.mylyn.wikitext.*core*.jar" /> - <include name="com.google.guava_*.jar" /> - </fileset> - - <!-- For Maven builds: use the compile_classpath --> - <pathelement path="${compile_classpath}" /> - </path> - - <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/ant/tasks.properties" /> + <taskdef resource="org/eclipse/mylyn/wikitext/ant/tasks.properties"/> <target name="build" description="Generate Eclipse help content for the Trace Compass Developer Guide"> <wikitext-to-eclipse-help markupLanguage="MediaWiki" diff --git a/doc/org.eclipse.tracecompass.doc.user/.externalToolBuilders/Trace Compass User Guide Builder.launch b/doc/org.eclipse.tracecompass.doc.user/.externalToolBuilders/Trace Compass User Guide Builder.launch deleted file mode 100644 index fb5f599666..0000000000 --- a/doc/org.eclipse.tracecompass.doc.user/.externalToolBuilders/Trace Compass User Guide Builder.launch +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> -<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/> -<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="build,build.index,"/> -<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> -<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> -<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/org.eclipse.tracecompass.doc.user" type="4"/> </resources>}"/> -<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.tracecompass.doc.user"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.tracecompass.doc.user/build.xml}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,clean"/> -<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> -</launchConfiguration> diff --git a/doc/org.eclipse.tracecompass.doc.user/.project b/doc/org.eclipse.tracecompass.doc.user/.project index b7299d0c46..27362ef6ec 100644 --- a/doc/org.eclipse.tracecompass.doc.user/.project +++ b/doc/org.eclipse.tracecompass.doc.user/.project @@ -6,20 +6,6 @@ </projects> <buildSpec> <buildCommand> - <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> - <triggers>clean,full,incremental,</triggers> - <arguments> - <dictionary> - <key>LaunchConfigHandle</key> - <value><project>/.externalToolBuilders/Trace Compass User Guide Builder.launch</value> - </dictionary> - <dictionary> - <key>incclean</key> - <value>true</value> - </dictionary> - </arguments> - </buildCommand> - <buildCommand> <name>org.eclipse.pde.ManifestBuilder</name> <arguments> </arguments> diff --git a/doc/org.eclipse.tracecompass.doc.user/build.properties b/doc/org.eclipse.tracecompass.doc.user/build.properties index 8225cb0aa5..1112b9833b 100644 --- a/doc/org.eclipse.tracecompass.doc.user/build.properties +++ b/doc/org.eclipse.tracecompass.doc.user/build.properties @@ -18,7 +18,4 @@ bin.includes = plugin.xml,\ doc/,\ reference/,\ index/ -jars.extra.classpath = platform:/plugin/org.eclipse.mylyn.wikitext.core,\ - platform:/plugin/org.eclipse.mylyn.wikitext.core.ant,\ - platform:/plugin/org.eclipse.mylyn.wikitext.mediawiki.core src.includes = about.html diff --git a/doc/org.eclipse.tracecompass.doc.user/build.xml b/doc/org.eclipse.tracecompass.doc.user/build.xml index f590645352..be151a63db 100644 --- a/doc/org.eclipse.tracecompass.doc.user/build.xml +++ b/doc/org.eclipse.tracecompass.doc.user/build.xml @@ -6,18 +6,7 @@ <property name="document.title" value="Trace Compass User Guide" /> - <path id="wikitext.tasks.classpath"> - <!-- Search in the local Eclipse plugins directory for the Wikitext plugin --> - <fileset dir="${osgi.syspath}" erroronmissingdir="false"> - <include name="org.eclipse.mylyn.wikitext.*core*.jar" /> - <include name="com.google.guava_*.jar" /> - </fileset> - - <!-- For Maven builds: use the compile_classpath --> - <pathelement path="${compile_classpath}" /> - </path> - - <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/ant/tasks.properties" /> + <taskdef resource="org/eclipse/mylyn/wikitext/ant/tasks.properties"/> <target name="build" description="Generate Eclipse help content for the Trace Compass User Guide"> <wikitext-to-eclipse-help markupLanguage="MediaWiki" diff --git a/doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki b/doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki index fda3697554..ed38aaa67d 100644 --- a/doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki +++ b/doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki @@ -2254,6 +2254,12 @@ The tooltip indicates: * the pointed state date and start/stop times * the pointed state duration (seconds) +A browser based tooltip is available that allows users to use hyperlink navigation or to copy text. To enable the feature select + +'''Window'''->'''Preferences'''->'''Tracing''' then checking '''Use browser based tooltips'''. It is known to be unstable on older platforms, if this instability is encountered, please submit your bug here: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=547563] + +[[Image:images/tooltippref.png]] + ==== Dynamics Filters ==== Dynamic filters are filters that are processed and applied each time the control flow view visible time range changes. diff --git a/doc/org.eclipse.tracecompass.doc.user/doc/images/Cfv_tooltip.png b/doc/org.eclipse.tracecompass.doc.user/doc/images/Cfv_tooltip.png Binary files differindex 45e3678a02..7c3d0d65fa 100644 --- a/doc/org.eclipse.tracecompass.doc.user/doc/images/Cfv_tooltip.png +++ b/doc/org.eclipse.tracecompass.doc.user/doc/images/Cfv_tooltip.png diff --git a/doc/org.eclipse.tracecompass.doc.user/doc/images/tooltippref.png b/doc/org.eclipse.tracecompass.doc.user/doc/images/tooltippref.png Binary files differnew file mode 100644 index 0000000000..55c0c52f3d --- /dev/null +++ b/doc/org.eclipse.tracecompass.doc.user/doc/images/tooltippref.png diff --git a/doc/org.eclipse.tracecompass.gdbtrace.doc.user/.externalToolBuilders/Trace Compass GDB Tracepoint Analysis User Guide Builder.launch b/doc/org.eclipse.tracecompass.gdbtrace.doc.user/.externalToolBuilders/Trace Compass GDB Tracepoint Analysis User Guide Builder.launch deleted file mode 100644 index 09d8c67f1a..0000000000 --- a/doc/org.eclipse.tracecompass.gdbtrace.doc.user/.externalToolBuilders/Trace Compass GDB Tracepoint Analysis User Guide Builder.launch +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> -<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/> -<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="build,build.index,"/> -<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> -<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> -<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/org.eclipse.tracecompass.gdbtrace.doc.user" type="4"/> </resources>}"/> -<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.tracecompass.gdbtrace.doc.user"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.tracecompass.gdbtrace.doc.user/build.xml}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,clean"/> -<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> -</launchConfiguration> diff --git a/doc/org.eclipse.tracecompass.gdbtrace.doc.user/.project b/doc/org.eclipse.tracecompass.gdbtrace.doc.user/.project index 0ff39d0f3f..4677e6a668 100644 --- a/doc/org.eclipse.tracecompass.gdbtrace.doc.user/.project +++ b/doc/org.eclipse.tracecompass.gdbtrace.doc.user/.project @@ -6,20 +6,6 @@ </projects> <buildSpec> <buildCommand> - <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> - <triggers>clean,full,incremental,</triggers> - <arguments> - <dictionary> - <key>LaunchConfigHandle</key> - <value><project>/.externalToolBuilders/Trace Compass GDB Tracepoint Analysis User Guide Builder.launch</value> - </dictionary> - <dictionary> - <key>incclean</key> - <value>true</value> - </dictionary> - </arguments> - </buildCommand> - <buildCommand> <name>org.eclipse.pde.ManifestBuilder</name> <arguments> </arguments> diff --git a/doc/org.eclipse.tracecompass.gdbtrace.doc.user/build.properties b/doc/org.eclipse.tracecompass.gdbtrace.doc.user/build.properties index 9e3ed57497..61580b68a4 100644 --- a/doc/org.eclipse.tracecompass.gdbtrace.doc.user/build.properties +++ b/doc/org.eclipse.tracecompass.gdbtrace.doc.user/build.properties @@ -17,7 +17,4 @@ bin.includes = META-INF/,\ plugin.properties,\ plugin.xml,\ index/ -jars.extra.classpath = platform:/plugin/org.eclipse.mylyn.wikitext.core,\ - platform:/plugin/org.eclipse.mylyn.wikitext.core.ant,\ - platform:/plugin/org.eclipse.mylyn.wikitext.mediawiki.core src.includes = about.html diff --git a/doc/org.eclipse.tracecompass.gdbtrace.doc.user/build.xml b/doc/org.eclipse.tracecompass.gdbtrace.doc.user/build.xml index c1df03ee4e..fe9472a759 100644 --- a/doc/org.eclipse.tracecompass.gdbtrace.doc.user/build.xml +++ b/doc/org.eclipse.tracecompass.gdbtrace.doc.user/build.xml @@ -14,18 +14,7 @@ <property name="document.title" value="GDB Tracepoint Analysis User Guide" /> - <path id="wikitext.tasks.classpath"> - <!-- Search in the local Eclipse plugins directory for the Wikitext plugin --> - <fileset dir="${osgi.syspath}" erroronmissingdir="false"> - <include name="org.eclipse.mylyn.wikitext.*core*.jar" /> - <include name="com.google.guava_*.jar" /> - </fileset> - - <!-- For Maven builds: use the compile_classpath --> - <pathelement path="${compile_classpath}" /> - </path> - - <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/ant/tasks.properties" /> + <taskdef resource="org/eclipse/mylyn/wikitext/ant/tasks.properties"/> <target name="build" description="Generate Eclipse help content for the Trace Compass GDB Tracepoint Analysis User Guide"> <wikitext-to-eclipse-help markupLanguage="MediaWiki" diff --git a/doc/org.eclipse.tracecompass.rcp.doc.user/.externalToolBuilders/Trace Compass RCP User Guide Builder.launch b/doc/org.eclipse.tracecompass.rcp.doc.user/.externalToolBuilders/Trace Compass RCP User Guide Builder.launch deleted file mode 100644 index 4834dc71c8..0000000000 --- a/doc/org.eclipse.tracecompass.rcp.doc.user/.externalToolBuilders/Trace Compass RCP User Guide Builder.launch +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> -<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/> -<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="build,build.index,"/> -<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> -<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> -<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/org.eclipse.tracecompass.rcp.doc.user" type="4"/> </resources>}"/> -<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.tracecompass.rcp.doc.user"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.tracecompass.rcp.doc.user/build.xml}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,clean"/> -<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> -</launchConfiguration> diff --git a/doc/org.eclipse.tracecompass.rcp.doc.user/.project b/doc/org.eclipse.tracecompass.rcp.doc.user/.project index 161c118b0e..aa8a448ac2 100644 --- a/doc/org.eclipse.tracecompass.rcp.doc.user/.project +++ b/doc/org.eclipse.tracecompass.rcp.doc.user/.project @@ -6,20 +6,6 @@ </projects> <buildSpec> <buildCommand> - <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> - <triggers>clean,full,incremental,</triggers> - <arguments> - <dictionary> - <key>LaunchConfigHandle</key> - <value><project>/.externalToolBuilders/Trace Compass RCP User Guide Builder.launch</value> - </dictionary> - <dictionary> - <key>incclean</key> - <value>true</value> - </dictionary> - </arguments> - </buildCommand> - <buildCommand> <name>org.eclipse.pde.ManifestBuilder</name> <arguments> </arguments> diff --git a/doc/org.eclipse.tracecompass.rcp.doc.user/build.properties b/doc/org.eclipse.tracecompass.rcp.doc.user/build.properties index 2698165e20..6bdfb110bd 100644 --- a/doc/org.eclipse.tracecompass.rcp.doc.user/build.properties +++ b/doc/org.eclipse.tracecompass.rcp.doc.user/build.properties @@ -17,7 +17,4 @@ bin.includes = plugin.xml,\ book.css,\ doc/,\ index/ -jars.extra.classpath = platform:/plugin/org.eclipse.mylyn.wikitext.core,\ - platform:/plugin/org.eclipse.mylyn.wikitext.core.ant,\ - platform:/plugin/org.eclipse.mylyn.wikitext.mediawiki.core src.includes = about.html diff --git a/doc/org.eclipse.tracecompass.rcp.doc.user/build.xml b/doc/org.eclipse.tracecompass.rcp.doc.user/build.xml index 6f4e1ca958..e200d656b4 100644 --- a/doc/org.eclipse.tracecompass.rcp.doc.user/build.xml +++ b/doc/org.eclipse.tracecompass.rcp.doc.user/build.xml @@ -6,18 +6,7 @@ <property name="document.title" value="Trace Compass RCP User Guide" /> - <path id="wikitext.tasks.classpath"> - <!-- Search in the local Eclipse plugins directory for the Wikitext plugin --> - <fileset dir="${osgi.syspath}" erroronmissingdir="false"> - <include name="org.eclipse.mylyn.wikitext.*core*.jar" /> - <include name="com.google.guava_*.jar" /> - </fileset> - - <!-- For Maven builds: use the compile_classpath --> - <pathelement path="${compile_classpath}" /> - </path> - - <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/ant/tasks.properties" /> + <taskdef resource="org/eclipse/mylyn/wikitext/ant/tasks.properties"/> <target name="build" description="Generate Eclipse help content for the Trace Compass RCP User Guide"> <wikitext-to-eclipse-help markupLanguage="MediaWiki" diff --git a/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/.project b/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/.project index b802a7e278..05b45f27f8 100644 --- a/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/.project +++ b/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/.project @@ -32,6 +32,5 @@ </buildSpec> <natures> <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.mylyn.wikitext.ui.wikiTextNature</nature> </natures> </projectDescription> diff --git a/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/build.properties b/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/build.properties index 92afd57221..c6b0509414 100644 --- a/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/build.properties +++ b/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/build.properties @@ -17,8 +17,5 @@ bin.includes = plugin.xml,\ book.css,\ doc/,\ index/ -jars.extra.classpath = platform:/plugin/org.eclipse.mylyn.wikitext.core,\ - platform:/plugin/org.eclipse.mylyn.wikitext.core.ant,\ - platform:/plugin/org.eclipse.mylyn.wikitext.mediawiki.core src.includes = about.html diff --git a/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/build.xml b/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/build.xml index 6b2d196a41..e19868d12f 100644 --- a/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/build.xml +++ b/doc/org.eclipse.tracecompass.tmf.pcap.doc.user/build.xml @@ -6,18 +6,7 @@ <property name="document.title" value="Pcap Network Tracing User Guide" /> - <path id="wikitext.tasks.classpath"> - <!-- Search in the local Eclipse plugins directory for the Wikitext plugin --> - <fileset dir="${osgi.syspath}" erroronmissingdir="false"> - <include name="org.eclipse.mylyn.wikitext.*core*.jar" /> - <include name="com.google.guava_*.jar" /> - </fileset> - - <!-- For Maven builds: use the compile_classpath --> - <pathelement path="${compile_classpath}" /> - </path> - - <taskdef classpathref="wikitext.tasks.classpath" resource="org/eclipse/mylyn/wikitext/core/ant/tasks.properties" /> + <taskdef resource="org/eclipse/mylyn/wikitext/ant/tasks.properties"/> <target name="build" description="Generate Eclipse help content for the Trace Compass Pcap User Guide"> <wikitext-to-eclipse-help markupLanguage="MediaWiki" diff --git a/doc/pom.xml b/doc/pom.xml index a7fa9dbadc..3439ffd7ba 100644 --- a/doc/pom.xml +++ b/doc/pom.xml @@ -26,6 +26,8 @@ <properties> <docDestination>/home/data/httpd/archive.eclipse.org/tracecompass/doc</docDestination> + <wikitext.version>3.0.7</wikitext.version> + <guava.version>21.0</guava.version> </properties> <modules> @@ -37,5 +39,36 @@ <module>org.eclipse.tracecompass.examples</module> </modules> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + + <dependencies> + <dependency> + <groupId>org.eclipse.mylyn.docs</groupId> + <artifactId>org.eclipse.mylyn.wikitext</artifactId> + <version>${wikitext.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.mylyn.docs</groupId> + <artifactId>org.eclipse.mylyn.wikitext.ant</artifactId> + <version>${wikitext.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.mylyn.docs</groupId> + <artifactId>org.eclipse.mylyn.wikitext.mediawiki</artifactId> + <version>${wikitext.version}</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>${guava.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> </project> diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlRemoteProfilesPreferencePage.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlRemoteProfilesPreferencePage.java index e6032a03af..70a01bac2a 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlRemoteProfilesPreferencePage.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlRemoteProfilesPreferencePage.java @@ -145,7 +145,9 @@ public class ControlRemoteProfilesPreferencePage extends PreferencePage implemen fImportButton.addSelectionListener(new SelectionListener() { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } @Override public void widgetSelected(SelectionEvent e) { diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/analysis.xml/org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.xml.futex/futex_analysis_lttng.xml b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/analysis.xml/org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.xml.futex/futex_analysis_lttng.xml index b54404c337..9dac81d7ae 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/analysis.xml/org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.xml.futex/futex_analysis_lttng.xml +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/analysis.xml/org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.xml.futex/futex_analysis_lttng.xml @@ -344,7 +344,7 @@ TRYLOCK_PI 136 264 </stateChange> </action> <fsm id="futex_lock_2_4"> - <precondition event="exit_syscall" cond="isTidValid" /> + <precondition event="*sys*" cond="isTidValid" /> <initialState> <transition event="sys_futex" cond="isTidValid:lock_op" target="syscall_entry_x" action="saveContext:set_operation:waiter_in"/> </initialState> @@ -354,7 +354,7 @@ TRYLOCK_PI 136 264 <final id="syscall_exit_x"/> </fsm> <fsm id="futex_unlock_2_4"> - <precondition event="exit_syscall" cond="isTidValid" /> + <precondition event="*sys*" cond="isTidValid" /> <initialState> <transition event="sys_futex" cond="isTidValid:unlock_op" target="syscall_entry_x" action="saveContext:set_operation"/> </initialState> @@ -373,7 +373,7 @@ TRYLOCK_PI 136 264 </state> </fsm> <fsm id="futex_lock_2_7"> - <precondition event="syscall_exit_futex" cond="isTidValid" /> + <precondition event="syscall_*_futex" cond="isTidValid" /> <initialState> <transition event="syscall_entry_futex" cond="isTidValid:lock_op" target="syscall_entry_x" action="saveContext:set_operation:waiter_in"/> </initialState> @@ -383,7 +383,7 @@ TRYLOCK_PI 136 264 <final id="syscall_exit_x"/> </fsm> <fsm id="futex_unlock_2_7"> - <precondition event="syscall_exit_futex" cond="isTidValid" /> + <precondition event="syscall_*_futex" cond="isTidValid" /> <initialState> <transition event="syscall_entry_futex" cond="isTidValid:unlock_op" target="syscall_entry_x" action="saveContext:set_operation"/> </initialState> diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/DisksIOViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/DisksIOViewTest.java index 5c8af8ba70..8fc7c28874 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/DisksIOViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/DisksIOViewTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Ericsson + * Copyright (c) 2017, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -14,7 +14,6 @@ import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -72,16 +71,6 @@ public class DisksIOViewTest extends XYDataProviderBaseTest { * should not be any activity. Then, we move to a time range where there are * write activity. Afterward, we test the zoom * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen * @throws URISyntaxException * if this URL is not formatted strictly according to to RFC2396 and * cannot be converted to a URI. @@ -89,12 +78,12 @@ public class DisksIOViewTest extends XYDataProviderBaseTest { * if an error occurs during the conversion */ @Test - public void testDiskView() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, URISyntaxException, IOException { + public void testDiskView() throws URISyntaxException, IOException { // Wait for analysis to finish. WaitUtils.waitForJobs(); - IViewPart viewSite = getSWTBotView().getViewReference().getView(true); - assertTrue(viewSite instanceof DiskIOActivityView); - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + IViewPart viewPart = getSWTBotView().getViewReference().getView(true); + assertTrue(viewPart instanceof DiskIOActivityView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer)); diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelMemoryUsageViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelMemoryUsageViewTest.java index a10f386eb2..ece5a804c7 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelMemoryUsageViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelMemoryUsageViewTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Ericsson + * Copyright (c) 2017, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -12,8 +12,6 @@ package org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.jdt.annotation.NonNull; import org.eclipse.swt.graphics.RGB; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; @@ -56,23 +54,12 @@ public class KernelMemoryUsageViewTest extends XYDataProviderBaseTest { /** * Simple test to check the Kernel Memory Usage view data model - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testKernelMemoryView() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - IViewPart viewSite = getSWTBotView().getViewReference().getView(true); - assertTrue(viewSite instanceof KernelMemoryUsageView); - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + public void testKernelMemoryView() { + IViewPart viewPart = getSWTBotView().getViewReference().getView(true); + assertTrue(viewPart instanceof KernelMemoryUsageView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer)); @@ -124,24 +111,12 @@ public class KernelMemoryUsageViewTest extends XYDataProviderBaseTest { /** * Test that the filter button works - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testFilter() throws NoSuchMethodException, SecurityException, - IllegalAccessException, IllegalArgumentException, InvocationTargetException { - IViewPart viewSite = getSWTBotView().getViewReference().getView(true); - assertTrue(viewSite instanceof KernelMemoryUsageView); - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + public void testFilter() { + IViewPart viewPart = getSWTBotView().getViewReference().getView(true); + assertTrue(viewPart instanceof KernelMemoryUsageView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer)); diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/OpenTraceStressTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/OpenTraceStressTest.java index 6d7bc513b0..61c0942d02 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/OpenTraceStressTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/OpenTraceStressTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 Ericsson + * Copyright (c) 2014, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -121,8 +121,8 @@ public class OpenTraceStressTest { SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); - // Add little delay so that treads have a chance to start - SWTBotUtils.delay(1000); + // Wait for editor so that threads have a chance to start + workbenchbot.editorByTitle(fTestFile.getName()); workbenchbot.closeAllEditors(); if (!status.isOK()) { diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesAndCpuViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesAndCpuViewTest.java index 94d41e9b1f..b4195ad529 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesAndCpuViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesAndCpuViewTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2017 Ericsson + * Copyright (c) 2016, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -13,8 +13,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.jdt.annotation.NonNull; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Tree; @@ -129,23 +127,12 @@ public class ResourcesAndCpuViewTest extends XYDataProviderBaseTest { /** * Simple test to check the CPU Usage view after getting signals. - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testCpuView() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - IViewPart viewSite = getSWTBotView().getViewReference().getView(true); - assertTrue(viewSite instanceof CpuUsageView); - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + public void testCpuView() { + IViewPart viewPart = getSWTBotView().getViewReference().getView(true); + assertTrue(viewPart instanceof CpuUsageView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer)); @@ -214,26 +201,15 @@ public class ResourcesAndCpuViewTest extends XYDataProviderBaseTest { /** * Test that the reset time range button resets the time range for both the CPU * view and the Resources view. - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testResetTimeRange() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public void testResetTimeRange() { ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace(); assertNotNull(activeTrace); - IViewPart viewSite = getSWTBotView().getViewReference().getView(true); - assertTrue(viewSite instanceof CpuUsageView); - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + IViewPart viewPart = getSWTBotView().getViewReference().getView(true); + assertTrue(viewPart instanceof CpuUsageView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); IWorkbenchPart part = fResourcesViewBot.getViewReference().getPart(false); diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/MemoryUsageViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/MemoryUsageViewTest.java index b57a1f07a3..644dd74c93 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/MemoryUsageViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/MemoryUsageViewTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2017 Ericsson + * Copyright (c) 2015, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -12,8 +12,6 @@ package org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.jdt.annotation.NonNull; import org.eclipse.swt.graphics.RGB; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; @@ -86,23 +84,12 @@ public class MemoryUsageViewTest extends XYDataProviderBaseTest { /** * Test Memory Usage data model - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testMemoryUsage() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - IViewPart viewSite = getSWTBotView().getViewReference().getView(true); - assertTrue(viewSite instanceof UstMemoryUsageView); - final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewSite); + public void testMemoryUsage() { + IViewPart viewPart = getSWTBotView().getViewReference().getView(true); + assertTrue(viewPart instanceof UstMemoryUsageView); + final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart); assertNotNull(chartViewer); fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer)); diff --git a/rcp/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java b/rcp/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java index 2516a02669..2233edaba3 100644 --- a/rcp/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java +++ b/rcp/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/ApplicationWorkbenchWindowAdvisor.java @@ -156,6 +156,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { * Default Constructor */ public PerspectiveListener() { + // Do nothing } @Override @@ -166,6 +167,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { @Override public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) { + // Do nothing } } diff --git a/rcp/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/TracingRcpPlugin.java b/rcp/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/TracingRcpPlugin.java index 7be98d98ab..f9a3c87d58 100644 --- a/rcp/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/TracingRcpPlugin.java +++ b/rcp/org.eclipse.tracecompass.rcp.ui/src/org/eclipse/tracecompass/internal/tracing/rcp/ui/TracingRcpPlugin.java @@ -56,6 +56,7 @@ public class TracingRcpPlugin extends AbstractUIPlugin { * The default constructor */ public TracingRcpPlugin() { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-e4.10.target b/releng/org.eclipse.tracecompass.target/tracecompass-e4.10.target index 0047162f0a..636c123f55 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-e4.10.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-e4.10.target @@ -1,15 +1,11 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?pde version="3.8"?><target name="tracecompass-e4.10" sequenceNumber="5"> +<?pde version="3.8"?><target name="tracecompass-e4.10" sequenceNumber="6"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/tools/cdt/releases/9.6/cdt-9.6.0/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eclipse.mylyn.wikitext_feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/mylyn/releases/3.21/"/> -</location> -<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.linuxtools.dataviewers.feature.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/linuxtools/update-7.1.0"/> </location> @@ -91,4 +87,4 @@ -Xmx512M</vmArgs> <programArgs>-consolelog</programArgs> </launcherArgs> -</target>
\ No newline at end of file +</target> diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-e4.11.target b/releng/org.eclipse.tracecompass.target/tracecompass-e4.11.target index 4e4055125e..afb0f05c67 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-e4.11.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-e4.11.target @@ -1,14 +1,10 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?><?pde version="3.8"?><target name="tracecompass-e4.11" sequenceNumber="5"> +<?xml version="1.0" encoding="UTF-8" standalone="no"?><?pde version="3.8"?><target name="tracecompass-e4.11" sequenceNumber="6"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/> <repository location="https://download.eclipse.org/tools/cdt/releases/9.7/cdt-9.7.0/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eclipse.mylyn.wikitext_feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/mylyn/releases/3.21/"/> -</location> -<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.linuxtools.dataviewers.feature.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/linuxtools/update-7.2.0"/> </location> @@ -90,4 +86,4 @@ -Xmx512M</vmArgs> <programArgs>-consolelog</programArgs> </launcherArgs> -</target>
\ No newline at end of file +</target> diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-e4.6.target b/releng/org.eclipse.tracecompass.target/tracecompass-e4.6.target index 9bc266f693..669acf6484 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-e4.6.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-e4.6.target @@ -1,15 +1,11 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?pde version="3.8"?><target name="tracecompass-e4.6" sequenceNumber="38"> +<?pde version="3.8"?><target name="tracecompass-e4.6" sequenceNumber="39"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/tools/cdt/releases/9.2/r.1"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eclipse.mylyn.wikitext_feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/mylyn/drops/3.21.1/v20161129-2023/"/> -</location> -<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.linuxtools.dataviewers.feature.feature.group" version="0.0.0"/> <repository location="http://archive.eclipse.org/linuxtools/update-5.3.0"/> </location> diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-e4.7.target b/releng/org.eclipse.tracecompass.target/tracecompass-e4.7.target index 90f1c73122..d18509d1b6 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-e4.7.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-e4.7.target @@ -1,15 +1,11 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?pde version="3.8"?><target name="tracecompass-e4.7" sequenceNumber="19"> +<?pde version="3.8"?><target name="tracecompass-e4.7" sequenceNumber="20"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/tools/cdt/releases/9.4/cdt-9.4.3/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eclipse.mylyn.wikitext_feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/mylyn/releases/3.21/"/> -</location> -<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.linuxtools.dataviewers.feature.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/linuxtools/update-oxygen-3/"/> </location> diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-e4.8.target b/releng/org.eclipse.tracecompass.target/tracecompass-e4.8.target index c79643eaac..c557140ca6 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-e4.8.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-e4.8.target @@ -1,15 +1,11 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?pde version="3.8"?><target name="tracecompass-e4.8" sequenceNumber="7"> +<?pde version="3.8"?><target name="tracecompass-e4.8" sequenceNumber="8"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/tools/cdt/builds/9.5/cdt-9.5.0-photon-rc4c/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eclipse.mylyn.wikitext_feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/mylyn/releases/3.21/"/> -</location> -<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.linuxtools.dataviewers.feature.feature.group" version="0.0.0"/> <repository location="https://download.eclipse.org/linuxtools/update-photon/"/> </location> diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-e4.9.target b/releng/org.eclipse.tracecompass.target/tracecompass-e4.9.target index acb454d367..808bd44734 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-e4.9.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-e4.9.target @@ -1,15 +1,11 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?pde version="3.8"?><target name="tracecompass-e4.9" sequenceNumber="6"> +<?pde version="3.8"?><target name="tracecompass-e4.9" sequenceNumber="7"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/tools/cdt/builds/9.5/cdt-9.5.3-simrel-2018-09-rc2/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eclipse.mylyn.wikitext_feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/mylyn/releases/3.21/"/> -</location> -<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.linuxtools.dataviewers.feature.feature.group" version="0.0.0"/> <repository location="http://download.eclipse.org/linuxtools/update-2018-09"/> </location> diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target b/releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target index 3a7c010437..082d45f573 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target @@ -1,36 +1,32 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?><?pde version="3.8"?><target name="tracecompass-eStaging" sequenceNumber="122"> +<?xml version="1.0" encoding="UTF-8" standalone="no"?><?pde version="3.8"?><target name="tracecompass-eStaging" sequenceNumber="124"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/> -<repository location="https://download.eclipse.org/tools/cdt/releases/9.7/cdt-9.7.0/"/> -</location> -<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.eclipse.mylyn.wikitext_feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/mylyn/releases/3.21/"/> +<repository location="https://download.eclipse.org/tools/cdt/builds/9.8/cdt-9.8.0-simrel-2019-06-m3/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.linuxtools.dataviewers.feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/linuxtools/update-7.2.0"/> +<repository location="https://download.eclipse.org/linuxtools/update-2019-06-m3/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.swtbot.eclipse.feature.group" version="0.0.0"/> <unit id="org.eclipse.swtbot.feature.group" version="0.0.0"/> <unit id="org.eclipse.swtbot.generator.feature.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/technology/swtbot/snapshots"/> +<repository location="https://download.eclipse.org/technology/swtbot/snapshots/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.remote.core" version="0.0.0"/> <unit id="org.eclipse.remote.ui" version="0.0.0"/> <unit id="org.eclipse.remote.jsch.core" version="0.0.0"/> <unit id="org.eclipse.remote.jsch.ui" version="0.0.0"/> -<repository location="http://download.eclipse.org/tools/ptp/builds/remote/photon/milestones/2019-03-M1"/> +<repository location="https://download.eclipse.org/tools/ptp/builds/remote/photon/milestones/2019-03-M1/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.tm.terminal.control" version="0.0.0"/> -<repository location="https://download.eclipse.org/tm/updates/4.5.100-SNAPSHOT/repository/"/> +<repository location="https://download.eclipse.org/tm/updates/4.5.101-SNAPSHOT/repository/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> -<repository location="http://download.eclipse.org/tools/cdt/launchbar/2.2/launchbar-2.2.3-simrel-2019-03-m2/"/> +<repository location="https://download.eclipse.org/tools/cdt/launchbar/2.3/launchbar-2.3.0-prerelease1/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.antlr.runtime" version="3.2.0.v201101311130"/> @@ -47,11 +43,11 @@ <unit id="javax.xml.bind" version="0.0.0"/> <unit id="javax.activation" version="0.0.0"/> <unit id="javax.xml.stream" version="0.0.0"/> -<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20190226160451/repository/"/> +<repository location="https://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.license.feature.group" version="0.0.0"/> -<repository location="http://download.eclipse.org/cbi/updates/license"/> +<repository location="https://download.eclipse.org/cbi/updates/license/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.platform.ide" version="0.0.0"/> @@ -67,21 +63,21 @@ <unit id="org.eclipse.ui.trace" version="0.0.0"/> <unit id="org.eclipse.ui.views.log" version="0.0.0"/> <unit id="org.eclipse.jdt.junit4.runtime" version="0.0.0"/> -<repository location="https://download.eclipse.org/eclipse/updates/4.12milestones/S-4.12M1-201904110625/"/> +<repository location="https://download.eclipse.org/eclipse/updates/4.12milestones/S-4.12M3-201905221800/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.tracecompass.testtraces.tracecompass-test-traces-ctf" version="1.7.2"/> -<repository location="http://archive.eclipse.org/tracecompass/tracecompass-test-traces/repository/1.7.2"/> +<repository location="https://archive.eclipse.org/tracecompass/tracecompass-test-traces/repository/1.7.2/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.wst.xml.core" version="0.0.0"/> <unit id="org.eclipse.wst.xml.ui" version="0.0.0"/> <unit id="org.eclipse.wst.xsd.core" version="0.0.0"/> -<repository location="https://download.eclipse.org/webtools/downloads/drops/R3.13.0/I-latest/repository/"/> +<repository location="https://download.eclipse.org/webtools/downloads/drops/R3.14.0/S-3.14.0.M3-20190528041652/repository/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.xsd" version="0.0.0"/> -<repository location="https://download.eclipse.org/modeling/emf/emf/builds/release/2.17"/> +<repository location="https://download.eclipse.org/modeling/emf/emf/builds/release/2.17/"/> </location> </locations> <targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/HTNode.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/HTNode.java index f79f61065b..a695abcbd1 100644 --- a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/HTNode.java +++ b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/HTNode.java @@ -22,6 +22,7 @@ import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.IntPredicate; import java.util.function.Predicate; import org.eclipse.jdt.annotation.NonNull; @@ -68,7 +69,7 @@ public class HTNode<E extends IHTInterval> implements IHTNode<E> { + 3 * Integer.BYTES + Byte.BYTES; - private static final Predicate<Integer> ALWAYS_TRUE = i -> true; + private static final IntPredicate ALWAYS_TRUE = i -> true; // ------------------------------------------------------------------------ // Attributes @@ -330,7 +331,7 @@ public class HTNode<E extends IHTInterval> implements IHTNode<E> { * @return Collection of sequence numbers of the child nodes that * intersect t, non-null empty collection if this is a Leaf Node */ - public final Collection<Integer> selectNextChildren(TimeRangeCondition timeCondition, Predicate<Integer> extraPredicate) { + public final Collection<Integer> selectNextChildren(TimeRangeCondition timeCondition, IntPredicate extraPredicate) { fNode.takeReadLock(); try { List<Integer> list = new ArrayList<>(); @@ -838,7 +839,7 @@ public class HTNode<E extends IHTInterval> implements IHTNode<E> { * The predicate on the intervals of a node * @return The predicate on the index in the core node data */ - public Predicate<Integer> getCoreDataPredicate(Predicate<E> predicate) { + public IntPredicate getCoreDataPredicate(Predicate<E> predicate) { return ALWAYS_TRUE; } @@ -1048,7 +1049,7 @@ public class HTNode<E extends IHTInterval> implements IHTNode<E> { * @throws RangeException * If t is out of the node's range */ - protected Collection<Integer> selectNextChildren(TimeRangeCondition timeCondition, Predicate<Integer> extraPredicate) + protected Collection<Integer> selectNextChildren(TimeRangeCondition timeCondition, IntPredicate extraPredicate) throws RangeException { CoreNodeData extraData = fExtraData; if (extraData != null) { diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/IHistoryTree.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/IHistoryTree.java index 0f4d8dc9c0..b56257590a 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/IHistoryTree.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/IHistoryTree.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2016 Ericsson, École Polytechnique de Montréal, and others + * Copyright (c) 2010, 2019 Ericsson, École Polytechnique de Montréal, and others * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -51,7 +51,7 @@ public interface IHistoryTree { HTNode createCoreNode(HTConfig config, int seqNumber, int parentSeqNumber, long start) throws IOException; /** - * Creates a new core node for the specific history tree + * Creates a new leaf node for the specific history tree * * @param config * Configuration of the History Tree @@ -62,7 +62,7 @@ public interface IHistoryTree { * The sequence number of this node's parent node * @param start * The earliest timestamp stored in this node - * @return The new core node + * @return The new leaf node * @throws IOException * any exception occurring while trying to read/create the * node diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlTimeGraphDataProviderTest.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlTimeGraphDataProviderTest.java index 0dea013d58..a49ab75ff7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlTimeGraphDataProviderTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlTimeGraphDataProviderTest.java @@ -21,14 +21,20 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlAnalysisModuleSource; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlUtils; -import org.eclipse.tracecompass.internal.tmf.core.model.filters.FetchParametersUtils; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphDataProvider; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphProviderFactory; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.XmlDataProviderManager; +import org.eclipse.tracecompass.internal.tmf.core.model.filters.FetchParametersUtils; +import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlUtils; import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles; @@ -38,21 +44,24 @@ import org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter; import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider; import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel; import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState; +import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel; import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel; import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel; -import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel; import org.eclipse.tracecompass.tmf.core.response.ITmfResponse; import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; +import org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; import org.junit.Before; import org.junit.Test; import org.w3c.dom.Element; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; /** * Test the XML time graph data provider with a simple test @@ -243,4 +252,42 @@ public class XmlTimeGraphDataProviderTest { } + /** + * Test the {@link DataDrivenTimeGraphProviderFactory} class + */ + @Test + public void testFactory() { + ITmfTrace trace = getTrace(); + assertNotNull(trace); + try { + runModule(trace); + // Get the view element from the file + Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.DATA_PROVIDER_SIMPLE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TIME_GRAPH_VIEW_ID); + assertNotNull(viewElement); + + TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement); + assertNotNull(tgViewCu); + DataDrivenTimeGraphProviderFactory timeGraphFactory = tgViewCu.generate(); + + // Test the factory with a simple trace + ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider = timeGraphFactory.create(trace); + assertNotNull(provider); + assertEquals(DataDrivenTimeGraphDataProvider.ID, provider.getId()); + + // Test the factory with an ID and state system + ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(trace, ITmfAnalysisModuleWithStateSystems.class, ANALYSIS_ID); + assertNotNull(module); + Iterable<@NonNull ITmfStateSystem> stateSystems = module.getStateSystems(); + assertNotNull(stateSystems); + provider = timeGraphFactory.create(trace, Objects.requireNonNull(Lists.newArrayList(stateSystems)), ANALYSIS_ID); + assertNotNull(provider); + assertEquals(ANALYSIS_ID, provider.getId()); + + } finally { + trace.dispose(); + TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace)); + } + + } + } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java index c9e8624708..b7b78772e7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java @@ -376,12 +376,12 @@ public class XmlUtilsTest { // Test the content of the pattern segment assertEquals("content size", expected.getContent().size(), actual.getContent().size()); - Iterator<Map.Entry<String, @NonNull ITmfStateValue>> it2 = expected.getContent().entrySet().iterator(); + Iterator<Map.Entry<String, @NonNull Object>> it2 = expected.getContent().entrySet().iterator(); for (int i = 0; i < expected.getContent().size(); i++) { - Map.Entry<String, @NonNull ITmfStateValue> expectedContent = it2.next(); - ITmfStateValue actualValue = actual.getContent().get(expectedContent.getKey()); + Map.Entry<String, @NonNull Object> expectedContent = it2.next(); + Object actualValue = actual.getContent().get(expectedContent.getKey()); assertNotNull("Content " + expectedContent.getKey() + " exists", actualValue); - assertEquals("Content value comparison " + i, 0, expectedContent.getValue().compareTo(actualValue)); + assertEquals("Content value comparison " + i, expectedContent, actualValue); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/stubs/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stubs/PatternSegmentFactoryStub.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/stubs/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stubs/PatternSegmentFactoryStub.java index 0237a37d0c..2ff4a768f0 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/stubs/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stubs/PatternSegmentFactoryStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/stubs/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stubs/PatternSegmentFactoryStub.java @@ -13,8 +13,6 @@ import java.util.Map; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.segment.TmfXmlPatternSegment; -import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; -import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; @@ -36,10 +34,10 @@ public class PatternSegmentFactoryStub { /** * The content for the segment TEST_2 */ - private static final @NonNull Map<@NonNull String, @NonNull ITmfStateValue> TEST_2_CONTENT = ImmutableMap - .of(NAME_FIELD_1, TmfStateValue.newValueLong(5l), - NAME_FIELD_2, TmfStateValue.newValueString("test"), - NAME_FIELD_3, TmfStateValue.newValueInt(1)); + private static final @NonNull Map<@NonNull String, @NonNull Object> TEST_2_CONTENT = ImmutableMap + .of(NAME_FIELD_1, 5l, + NAME_FIELD_2, "test", + NAME_FIELD_3, 1); /** * Start event for pattern segment TEST_2 diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_data_provider_simple.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_data_provider_simple.xml index 464966b3b8..5b9156d89e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_data_provider_simple.xml +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/test_data_provider_simple.xml @@ -47,7 +47,6 @@ <entry path="CPU/*"> <display type="self" /> - <name type="self" /> </entry> </xyView> @@ -59,7 +58,6 @@ <entry path="CPU/*" displayType="delta"> <display type="self" /> - <name type="self" /> </entry> </xyView> </tmfxml> diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlTimeGraphEntryCu.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlOutputEntryCu.java index 67e5922939..5e1b2434cf 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlTimeGraphEntryCu.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlOutputEntryCu.java @@ -17,7 +17,8 @@ import java.util.stream.Collectors; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.Activator; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphEntry; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntry; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYDataProvider.DisplayType; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlUtils; import org.w3c.dom.Element; @@ -27,9 +28,9 @@ import org.w3c.dom.Element; * * @author Geneviève Bastien */ -public class TmfXmlTimeGraphEntryCu implements IDataDrivenCompilationUnit { +public class TmfXmlOutputEntryCu implements IDataDrivenCompilationUnit { - private final List<TmfXmlTimeGraphEntryCu> fChildrenEntries; + private final List<TmfXmlOutputEntryCu> fChildrenEntries; private final String fPath; private final @Nullable String fAnalysisId; private final boolean fDisplayText; @@ -37,13 +38,15 @@ public class TmfXmlTimeGraphEntryCu implements IDataDrivenCompilationUnit { private final @Nullable TmfXmlStateSystemPathCu fIdCu; private final @Nullable TmfXmlStateSystemPathCu fParentCu; private final @Nullable TmfXmlStateSystemPathCu fNameCu; + private final DisplayType fDisplayType; - private TmfXmlTimeGraphEntryCu(List<TmfXmlTimeGraphEntryCu> childrenCu, String path, + private TmfXmlOutputEntryCu(List<TmfXmlOutputEntryCu> childrenCu, String path, @Nullable String analysisId, boolean displayText, @Nullable TmfXmlStateSystemPathCu displayCu, @Nullable TmfXmlStateSystemPathCu idCu, @Nullable TmfXmlStateSystemPathCu parentCu, - @Nullable TmfXmlStateSystemPathCu nameCu) { + @Nullable TmfXmlStateSystemPathCu nameCu, + DisplayType displayType) { fChildrenEntries = childrenCu; fPath = path; fAnalysisId = analysisId; @@ -52,19 +55,20 @@ public class TmfXmlTimeGraphEntryCu implements IDataDrivenCompilationUnit { fIdCu = idCu; fParentCu = parentCu; fNameCu = nameCu; + fDisplayType = displayType; } @Override - public DataDrivenTimeGraphEntry generate() { - List<DataDrivenTimeGraphEntry> entries = fChildrenEntries.stream() - .map(TmfXmlTimeGraphEntryCu::generate) + public DataDrivenOutputEntry generate() { + List<DataDrivenOutputEntry> entries = fChildrenEntries.stream() + .map(TmfXmlOutputEntryCu::generate) .collect(Collectors.toList()); DataDrivenStateSystemPath display = fDisplayCu != null ? fDisplayCu.generate() : null; DataDrivenStateSystemPath id = fIdCu != null ? fIdCu.generate() : null; DataDrivenStateSystemPath parent = fParentCu != null ? fParentCu.generate() : null; DataDrivenStateSystemPath name = fNameCu != null ? fNameCu.generate() : null; - return new DataDrivenTimeGraphEntry(entries, fPath, fAnalysisId, fDisplayText, - display, id, parent, name); + return new DataDrivenOutputEntry(entries, fPath, fAnalysisId, fDisplayText, + display, id, parent, name, fDisplayType); } /** @@ -77,7 +81,7 @@ public class TmfXmlTimeGraphEntryCu implements IDataDrivenCompilationUnit { * @return The time graph entry compilation unit or <code>null</code> if the * entry did not compile properly. */ - public static @Nullable TmfXmlTimeGraphEntryCu compile(AnalysisCompilationData compilationData, Element entryEl) { + public static @Nullable TmfXmlOutputEntryCu compile(AnalysisCompilationData compilationData, Element entryEl) { // Get the path in the state system String path = entryEl.getAttribute(TmfXmlStrings.PATH); @@ -100,9 +104,9 @@ public class TmfXmlTimeGraphEntryCu implements IDataDrivenCompilationUnit { } // Compile children entries - List<TmfXmlTimeGraphEntryCu> childrenCu = new ArrayList<>(); + List<TmfXmlOutputEntryCu> childrenCu = new ArrayList<>(); for (Element childEl : entryElements) { - TmfXmlTimeGraphEntryCu childCu = compile(compilationData, childEl); + TmfXmlOutputEntryCu childCu = compile(compilationData, childEl); if (childCu != null) { childrenCu.add(childCu); } @@ -155,11 +159,17 @@ public class TmfXmlTimeGraphEntryCu implements IDataDrivenCompilationUnit { analysisId = null; } - // Get the state system to use to populate those entries, by default, it - // is the same as the parent + // Get whether to display the text, applies to time graphs boolean displayText = Boolean.parseBoolean(entryEl.getAttribute(TmfXmlStrings.DISPLAY_TEXT)); - return new TmfXmlTimeGraphEntryCu(childrenCu, path, analysisId, displayText, displayCu, idCu, parentCu, nameCu); + // Get the type of display, applies to XY entries + String displayTypeStr = entryEl.getAttribute(TmfXmlStrings.DISPLAY_TYPE); + DisplayType displayType = DisplayType.ABSOLUTE; + if (displayTypeStr.equalsIgnoreCase(TmfXmlStrings.DISPLAY_TYPE_DELTA)) { + displayType = DisplayType.DELTA; + } + + return new TmfXmlOutputEntryCu(childrenCu, path, analysisId, displayText, displayCu, idCu, parentCu, nameCu, displayType); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlTimeGraphViewCu.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlTimeGraphViewCu.java index 53ea8f020d..3385b370ee 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlTimeGraphViewCu.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlTimeGraphViewCu.java @@ -17,7 +17,7 @@ import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenPresentationState; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphEntry; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntry; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphProviderFactory; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlUtils; @@ -31,10 +31,10 @@ import org.w3c.dom.Element; public class TmfXmlTimeGraphViewCu implements IDataDrivenCompilationUnit { private final List<DataDrivenPresentationState> fValues; - private final List<TmfXmlTimeGraphEntryCu> fEntries; + private final List<TmfXmlOutputEntryCu> fEntries; private final Set<String> fAnalysisIds; - private TmfXmlTimeGraphViewCu(List<DataDrivenPresentationState> values, List<TmfXmlTimeGraphEntryCu> entriesCu, Set<String> analysisIds) { + private TmfXmlTimeGraphViewCu(List<DataDrivenPresentationState> values, List<TmfXmlOutputEntryCu> entriesCu, Set<String> analysisIds) { fValues = values; fEntries = entriesCu; fAnalysisIds = analysisIds; @@ -42,8 +42,8 @@ public class TmfXmlTimeGraphViewCu implements IDataDrivenCompilationUnit { @Override public DataDrivenTimeGraphProviderFactory generate() { - List<DataDrivenTimeGraphEntry> entries = fEntries.stream() - .map(TmfXmlTimeGraphEntryCu::generate) + List<DataDrivenOutputEntry> entries = fEntries.stream() + .map(TmfXmlOutputEntryCu::generate) .collect(Collectors.toList()); return new DataDrivenTimeGraphProviderFactory(entries, fAnalysisIds, fValues); } @@ -69,9 +69,9 @@ public class TmfXmlTimeGraphViewCu implements IDataDrivenCompilationUnit { Set<@NonNull String> analysisIds = TmfXmlUtils.getViewAnalysisIds(viewElement); List<Element> entries = TmfXmlUtils.getChildElements(viewElement, TmfXmlStrings.ENTRY_ELEMENT); - List<TmfXmlTimeGraphEntryCu> entriesCu = new ArrayList<>(); + List<TmfXmlOutputEntryCu> entriesCu = new ArrayList<>(); for (Element entry : entries) { - TmfXmlTimeGraphEntryCu entryCu = TmfXmlTimeGraphEntryCu.compile(compilationData, entry); + TmfXmlOutputEntryCu entryCu = TmfXmlOutputEntryCu.compile(compilationData, entry); if (entryCu != null) { entriesCu.add(entryCu); } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlXYViewCu.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlXYViewCu.java new file mode 100644 index 0000000000..b6cc5128d4 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/compile/TmfXmlXYViewCu.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2019 École Polytechnique de Montréal + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntry; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYProviderFactory; +import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; +import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlUtils; +import org.w3c.dom.Element; + +/** + * Compilation unit for XY views + * + * @author Geneviève Bastien + */ +public class TmfXmlXYViewCu implements IDataDrivenCompilationUnit { + + private final List<TmfXmlOutputEntryCu> fEntries; + private final Set<String> fAnalysisIds; + + private TmfXmlXYViewCu(List<TmfXmlOutputEntryCu> entriesCu, Set<String> analysisIds) { + fEntries = entriesCu; + fAnalysisIds = analysisIds; + } + + @Override + public DataDrivenXYProviderFactory generate() { + List<DataDrivenOutputEntry> entries = fEntries.stream() + .map(TmfXmlOutputEntryCu::generate) + .collect(Collectors.toList()); + return new DataDrivenXYProviderFactory(entries, fAnalysisIds); + } + + /** + * Compile a time graph view XML element + * + * @param compilationData + * Analysis compilation data + * @param viewElement + * The XML view element + * @return The time graph compilation unit + */ + public static @Nullable TmfXmlXYViewCu compile(AnalysisCompilationData compilationData, Element viewElement) { + + Set<String> analysisIds = TmfXmlUtils.getViewAnalysisIds(viewElement); + List<Element> entries = TmfXmlUtils.getChildElements(viewElement, TmfXmlStrings.ENTRY_ELEMENT); + + List<TmfXmlOutputEntryCu> entriesCu = new ArrayList<>(); + for (Element entry : entries) { + TmfXmlOutputEntryCu entryCu = TmfXmlOutputEntryCu.compile(compilationData, entry); + if (entryCu != null) { + entriesCu.add(entryCu); + } + } + + return new TmfXmlXYViewCu(entriesCu, analysisIds); + } + +} diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/DataDrivenActionSegment.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/DataDrivenActionSegment.java index 2f6ece3deb..d0c682ccb7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/DataDrivenActionSegment.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/DataDrivenActionSegment.java @@ -23,7 +23,6 @@ import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.patter import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.segment.TmfXmlPatternSegment; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; -import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; /** @@ -75,10 +74,19 @@ public class DataDrivenActionSegment implements DataDrivenAction { Object segmentName = fType.getValue(event, ITmfStateSystem.ROOT_ATTRIBUTE, scenarioInfo, container); - Map<String, ITmfStateValue> fields = new HashMap<>(); + Map<String, Object> fields = new HashMap<>(); for (Entry<String, DataDrivenValue> field : fFields.entrySet()) { Object value = field.getValue().getValue(event, ITmfStateSystem.ROOT_ATTRIBUTE, scenarioInfo, container); - fields.put(field.getKey(), value instanceof ITmfStateValue ? (ITmfStateValue) value : TmfStateValue.newValue(value)); + // Segment content does not support null values + if (value != null) { + if (value instanceof ITmfStateValue) { + if (!((ITmfStateValue) value).isNull()) { + fields.put(field.getKey(), Objects.requireNonNull(((ITmfStateValue) value).unboxValue())); + } + } else { + fields.put(field.getKey(), value); + } + } } // Set the start time diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/DataDrivenStateSystemPath.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/DataDrivenStateSystemPath.java index e15d9332f2..c4d0b4e075 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/DataDrivenStateSystemPath.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/DataDrivenStateSystemPath.java @@ -36,8 +36,20 @@ public class DataDrivenStateSystemPath implements IDataDrivenRuntimeObject { * @param attributes * The list of state values whose resolved value will be the * attributes in the state system + * */ + public DataDrivenStateSystemPath(List<DataDrivenValue> attributes) { + this(attributes, IBaseQuarkProvider.IDENTITY_BASE_QUARK); + } + + /** + * Constructor + * + * @param attributes + * The list of state values whose resolved value will be the + * attributes in the state system * @param quarkProvider * The provider for the base quark + * */ public DataDrivenStateSystemPath(List<DataDrivenValue> attributes, IBaseQuarkProvider quarkProvider) { fAttributes = attributes; diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/values/DataDrivenValueEventField.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/values/DataDrivenValueEventField.java index 52d0651b2d..02fce51130 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/values/DataDrivenValueEventField.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/fsm/model/values/DataDrivenValueEventField.java @@ -61,7 +61,13 @@ public class DataDrivenValueEventField extends DataDrivenValue { /* If the field does not exist, see if it's a special case */ if (field == null) { - if (fFieldName.equalsIgnoreCase(TmfXmlStrings.CPU)) { + final ITmfEventField splitFieldName = event.getContent().getField(fFieldName.split("\\.")); //$NON-NLS-1$ + if (splitFieldName != null) { + fieldValue = splitFieldName.getValue(); + if (fieldValue != null) { + return fieldValue; + } + } else if (fFieldName.equalsIgnoreCase(TmfXmlStrings.CPU)) { /* A "CPU" field will return the CPU aspect if available */ Integer cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event); if (cpu != null) { diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/module/XmlXYDataProvider.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/module/XmlXYDataProvider.java index 2e5a74386b..e1ca103076 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/module/XmlXYDataProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/module/XmlXYDataProvider.java @@ -75,8 +75,7 @@ public class XmlXYDataProvider extends AbstractTmfTraceDataProvider private static final String TITLE = Objects.requireNonNull(Messages.XmlDataProvider_DefaultXYTitle); /** - * Extension point ID - * @since 2.4 + * Data provider ID */ public static final String ID = "org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlXYDataProvider"; //$NON-NLS-1$ private static final String SPLIT_STRING = "/"; //$NON-NLS-1$ diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphEntry.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenOutputEntry.java index 84394f6f25..12269407ec 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphEntry.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenOutputEntry.java @@ -25,7 +25,8 @@ import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDri import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.IDataDrivenRuntimeObject; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.IAnalysisDataContainer; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphEntryModel.EntryBuilder; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntryModel.EntryBuilder; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYDataProvider.DisplayType; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; import org.eclipse.tracecompass.statesystem.core.StateSystemUtils; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; @@ -39,7 +40,7 @@ import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; * * @author Geneviève Bastien */ -public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { +public class DataDrivenOutputEntry implements IDataDrivenRuntimeObject { /** * Integer to get an ID from a state system and quark @@ -73,8 +74,10 @@ public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { * The state system to query * @param quark * The quark to use to get the data + * @param displayType + * The way to compute the data to show */ - void registerQuark(long id, ITmfStateSystem ss, int quark); + void registerQuark(long id, ITmfStateSystem ss, int quark, DisplayType displayType); } private static class DataContainer implements IAnalysisDataContainer { @@ -100,7 +103,7 @@ public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { private static final String SPLIT_STRING = "/"; //$NON-NLS-1$ private static final Map<ITmfStateSystem, DataContainer> SS_TO_CONTAINER = new WeakHashMap<>(); - private final List<DataDrivenTimeGraphEntry> fChildrenEntries; + private final List<DataDrivenOutputEntry> fChildrenEntries; private final String fPath; private final @Nullable String fAnalysisId; private final boolean fDisplayText; @@ -108,6 +111,7 @@ public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { private final @Nullable DataDrivenStateSystemPath fId; private final @Nullable DataDrivenStateSystemPath fParent; private final @Nullable DataDrivenStateSystemPath fName; + private final DisplayType fDisplayType; /** * Constructor @@ -132,13 +136,17 @@ public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { * is the ID of another entry at the same level * @param name * The state ssytem path for the name of the entry + * @param displayType + * The type of value to display, whether absolute or relative to + * previous value */ - public DataDrivenTimeGraphEntry(List<DataDrivenTimeGraphEntry> entries, String path, + public DataDrivenOutputEntry(List<DataDrivenOutputEntry> entries, String path, @Nullable String analysisId, boolean displayText, @Nullable DataDrivenStateSystemPath display, @Nullable DataDrivenStateSystemPath id, @Nullable DataDrivenStateSystemPath parent, - @Nullable DataDrivenStateSystemPath name) { + @Nullable DataDrivenStateSystemPath name, + DisplayType displayType) { fChildrenEntries = entries; fPath = path; fAnalysisId = analysisId; @@ -147,6 +155,7 @@ public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { fId = id; fParent = parent; fName = name; + fDisplayType = displayType; } /** @@ -225,8 +234,8 @@ public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { DataDrivenStateSystemPath namePath = fName; DataDrivenStateSystemPath idPath = fId; DataDrivenStateSystemPath parentPath = fParent; - Map<String, DataDrivenTimeGraphEntryModel.EntryBuilder> entryMap = new HashMap<>(); - List<DataDrivenTimeGraphEntryModel.EntryBuilder> entries = new ArrayList<>(); + Map<String, DataDrivenOutputEntryModel.EntryBuilder> entryMap = new HashMap<>(); + List<DataDrivenOutputEntryModel.EntryBuilder> entries = new ArrayList<>(); List<TimeGraphEntryModel> entryList = new ArrayList<>(); for (int quark : quarks) { @@ -241,7 +250,7 @@ public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { // The entry has no display quark, do not display continue; } - callback.registerQuark(id, ss, displayQuark); + callback.registerQuark(id, ss, displayQuark, fDisplayType); try { @@ -296,12 +305,12 @@ public class DataDrivenTimeGraphEntry implements IDataDrivenRuntimeObject { xmlParentId = getFirstValue(quark, parentPath, container); } - EntryBuilder entryBuilder = new DataDrivenTimeGraphEntryModel.EntryBuilder(id, parentEntryId, displayQuark, name, xmlId, xmlParentId, entryStart, entryEnd, fDisplayText); + EntryBuilder entryBuilder = new DataDrivenOutputEntryModel.EntryBuilder(id, parentEntryId, displayQuark, name, xmlId, xmlParentId, entryStart, entryEnd, fDisplayText, fDisplayType); entryMap.put(xmlId, entryBuilder); entries.add(entryBuilder); /* Process the children entry of this entry */ - for (DataDrivenTimeGraphEntry subEntry : fChildrenEntries) { + for (DataDrivenOutputEntry subEntry : fChildrenEntries) { @NonNull String regex = prevRegex.isEmpty() ? regexName : prevRegex + '/' + regexName; entryList.addAll(subEntry.buildEntries(ss, entryBuilder.getId(), trace, quark, regex, currentEnd, idGenerator, callback)); } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphEntryModel.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenOutputEntryModel.java index dedf285741..3e28fc3957 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphEntryModel.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenOutputEntryModel.java @@ -11,6 +11,7 @@ package org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYDataProvider.DisplayType; import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphEntryModel; import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel; @@ -20,11 +21,11 @@ import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel; * @author Loic Prieur-Drevon * @since 3.0 */ -public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { +public class DataDrivenOutputEntryModel extends TimeGraphEntryModel { /** - * Builder for the {@link DataDrivenTimeGraphEntryModel}, encapsulates logic and fields - * necessary to build the {@link DataDrivenTimeGraphEntryModel}, but that we do not + * Builder for the {@link DataDrivenOutputEntryModel}, encapsulates logic and fields + * necessary to build the {@link DataDrivenOutputEntryModel}, but that we do not * want to share with the client * * @author Loic Prieur-Drevon @@ -40,6 +41,7 @@ public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { private String fXmlParentId = StringUtils.EMPTY; private final boolean fDisplayLabel; private final int fDisplayQuark; + private final DisplayType fDisplayType; /** * Constructor @@ -63,8 +65,10 @@ public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { * The timestamp of the entry end * @param displayText * Whether to display some text as label + * @param displayType + * The type of display for this entry */ - public EntryBuilder(long id, long parentEntryId, int displayQuark, String name, String xmlId, String xmlParentId, long entryStart, long entryEnd, boolean displayText) { + public EntryBuilder(long id, long parentEntryId, int displayQuark, String name, String xmlId, String xmlParentId, long entryStart, long entryEnd, boolean displayText, DisplayType displayType) { fId = id; fName = name; fXmlId = xmlId; @@ -74,6 +78,7 @@ public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { fParentId = parentEntryId; fDisplayLabel = displayText; fDisplayQuark = displayQuark; + fDisplayType = displayType; } @Override @@ -102,7 +107,7 @@ public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { } /** - * Getter for this {@link DataDrivenTimeGraphEntryModel}'s XML ID + * Getter for this {@link DataDrivenOutputEntryModel}'s XML ID * * @return this entry's XML ID. */ @@ -130,12 +135,12 @@ public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { } /** - * Generate an {@link DataDrivenTimeGraphEntryModel} from the builder. + * Generate an {@link DataDrivenOutputEntryModel} from the builder. * - * @return a new {@link DataDrivenTimeGraphEntryModel} instance. + * @return a new {@link DataDrivenOutputEntryModel} instance. */ - public DataDrivenTimeGraphEntryModel build() { - return new DataDrivenTimeGraphEntryModel(fId, fParentId, fDisplayQuark, fName, fStart, fEnd, fXmlId, fXmlParentId, fDisplayLabel); + public DataDrivenOutputEntryModel build() { + return new DataDrivenOutputEntryModel(fId, fParentId, fDisplayQuark, fName, fStart, fEnd, fXmlId, fXmlParentId, fDisplayLabel, fDisplayType); } @Override @@ -149,13 +154,15 @@ public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { private final String fXmlParentId; private final boolean fShowText; private final int fDisplayQuark; + private final DisplayType fDisplayType; /** * @param id * unique entry model id * @param parentId * parent's unique entry model id - * @param displayQuark The quark to display + * @param displayQuark + * The quark to display * @param name * default entry name * @param startTime @@ -168,19 +175,22 @@ public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { * XML parent ID * @param showText * if the text should be shown for this entry or not. + * @param displayType + * The type of display for this entry */ - public DataDrivenTimeGraphEntryModel(long id, long parentId, int displayQuark, String name, long startTime, long endTime, - String xmlId, String xmlParentId, boolean showText) { + public DataDrivenOutputEntryModel(long id, long parentId, int displayQuark, String name, long startTime, long endTime, + String xmlId, String xmlParentId, boolean showText, DisplayType displayType) { super(id, parentId, name, startTime, endTime); fXmlId = xmlId; fXmlParentId = xmlParentId; fShowText = showText; fDisplayQuark = displayQuark; + fDisplayType = displayType; } /** - * Getter for this {@link DataDrivenTimeGraphEntryModel}'s XML ID + * Getter for this {@link DataDrivenOutputEntryModel}'s XML ID * * @return this entry's XML ID. */ @@ -215,4 +225,13 @@ public class DataDrivenTimeGraphEntryModel extends TimeGraphEntryModel { return fDisplayQuark; } + /** + * Get the type of display computation to do for this entry + * + * @return The display type + */ + public DisplayType getDisplayType() { + return fDisplayType; + } + } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphDataProvider.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphDataProvider.java index 8843235bfb..64a5451cf6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphDataProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphDataProvider.java @@ -26,8 +26,8 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphEntry.IdGetter; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphEntry.QuarkCallback; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntry.IdGetter; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntry.QuarkCallback; import org.eclipse.tracecompass.internal.tmf.core.model.AbstractTmfTraceDataProvider; import org.eclipse.tracecompass.internal.tmf.core.model.filters.FetchParametersUtils; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; @@ -73,7 +73,7 @@ public class DataDrivenTimeGraphDataProvider extends AbstractTmfTraceDataProvide private static final AtomicLong sfAtomicId = new AtomicLong(); private final List<ITmfStateSystem> fSs; - private final List<DataDrivenTimeGraphEntry> fEntries; + private final List<DataDrivenOutputEntry> fEntries; private final List<DataDrivenPresentationState> fValues; /** @@ -83,7 +83,8 @@ public class DataDrivenTimeGraphDataProvider extends AbstractTmfTraceDataProvide private final Map<Long, Pair<ITmfStateSystem, Integer>> fIDToDisplayQuark = new HashMap<>(); private final IdGetter fIdGenerator = (ss, quark) -> fBaseQuarkToId.row(ss).computeIfAbsent(quark, s -> sfAtomicId.getAndIncrement()); - private final QuarkCallback fQuarkCallback = (id, ss, quark) -> fIDToDisplayQuark.put(id, new Pair<>(ss, quark)); + private final QuarkCallback fQuarkCallback = (id, ss, quark, dt) -> fIDToDisplayQuark.put(id, new Pair<>(ss, quark)); + private final String fId; /** * Constructor @@ -96,12 +97,15 @@ public class DataDrivenTimeGraphDataProvider extends AbstractTmfTraceDataProvide * The entries * @param values * The presentation values + * @param id + * The ID of the data provider */ - public DataDrivenTimeGraphDataProvider(ITmfTrace trace, List<ITmfStateSystem> stateSystems, List<DataDrivenTimeGraphEntry> entries, List<DataDrivenPresentationState> values) { + public DataDrivenTimeGraphDataProvider(ITmfTrace trace, List<ITmfStateSystem> stateSystems, List<DataDrivenOutputEntry> entries, List<DataDrivenPresentationState> values, @Nullable String id) { super(trace); fSs = stateSystems; fEntries = entries; fValues = values; + fId = (id == null) ? ID : id; } @Override @@ -120,7 +124,7 @@ public class DataDrivenTimeGraphDataProvider extends AbstractTmfTraceDataProvide TimeGraphEntryModel ssEntry = new TimeGraphEntryModel(id, -1, traceName, start, end); entryList.add(ssEntry); - for (DataDrivenTimeGraphEntry entry : fEntries) { + for (DataDrivenOutputEntry entry : fEntries) { entryList.addAll(entry.buildEntries(ss, ssEntry.getId(), getTrace(), -1, StringUtils.EMPTY, end, fIdGenerator, fQuarkCallback)); } } @@ -133,7 +137,7 @@ public class DataDrivenTimeGraphDataProvider extends AbstractTmfTraceDataProvide @Override public @NonNull String getId() { - return ID; + return fId; } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphProviderFactory.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphProviderFactory.java index cc46649203..80c7f2f59d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphProviderFactory.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenTimeGraphProviderFactory.java @@ -37,7 +37,7 @@ import com.google.common.collect.Iterables; public class DataDrivenTimeGraphProviderFactory implements IDataDrivenRuntimeObject { private final List<DataDrivenPresentationState> fValues; - private final List<DataDrivenTimeGraphEntry> fEntries; + private final List<DataDrivenOutputEntry> fEntries; private final Set<String> fAnalysisIds; /** @@ -51,7 +51,7 @@ public class DataDrivenTimeGraphProviderFactory implements IDataDrivenRuntimeObj * The values to use to display the labels and colors of this * time graph */ - public DataDrivenTimeGraphProviderFactory(List<DataDrivenTimeGraphEntry> entries, Set<String> analysisIds, List<DataDrivenPresentationState> values) { + public DataDrivenTimeGraphProviderFactory(List<DataDrivenOutputEntry> entries, Set<String> analysisIds, List<DataDrivenPresentationState> values) { fValues = values; fEntries = entries; fAnalysisIds = analysisIds; @@ -92,7 +92,22 @@ public class DataDrivenTimeGraphProviderFactory implements IDataDrivenRuntimeObj module.getStateSystems().forEach(sss::add); } } - return (sss.isEmpty() ? null : new DataDrivenTimeGraphDataProvider(trace, sss, fEntries, fValues)); + return (sss.isEmpty() ? null : new DataDrivenTimeGraphDataProvider(trace, sss, fEntries, fValues, null)); + } + + /** + * Create a data provider with state systems already available + * + * @param trace + * The trace this data provider is associated with + * @param stateSystems + * The state systems to use + * @param id + * The ID of the data provider to create + * @return The data provider + */ + public ITimeGraphDataProvider<TimeGraphEntryModel> create(ITmfTrace trace, List<ITmfStateSystem> stateSystems, String id) { + return new DataDrivenTimeGraphDataProvider(trace, stateSystems, fEntries, fValues, id); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenXYDataProvider.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenXYDataProvider.java new file mode 100644 index 0000000000..31e675a254 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenXYDataProvider.java @@ -0,0 +1,301 @@ +/******************************************************************************* + * Copyright (c) 2019 École Polytechnique de Montréal + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +import org.apache.commons.lang3.StringUtils; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.Messages; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntry.IdGetter; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntry.QuarkCallback; +import org.eclipse.tracecompass.internal.tmf.core.model.AbstractTmfTraceDataProvider; +import org.eclipse.tracecompass.internal.tmf.core.model.TmfXyResponseFactory; +import org.eclipse.tracecompass.internal.tmf.core.model.filters.FetchParametersUtils; +import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; +import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; +import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; +import org.eclipse.tracecompass.tmf.core.model.CommonStatusMessage; +import org.eclipse.tracecompass.tmf.core.model.YModel; +import org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter; +import org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter; +import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel; +import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel; +import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel; +import org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider; +import org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel; +import org.eclipse.tracecompass.tmf.core.model.xy.IYModel; +import org.eclipse.tracecompass.tmf.core.response.ITmfResponse; +import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse; +import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; + +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Maps; +import com.google.common.collect.Table; + +/** + * This data provider will return XY models (wrapped in a response) based on a + * query filter. The models can be used afterwards by any viewer to draw XY + * charts. Model returned is for XML analysis. + * + * TODO: There is code duplication with the time graph data provider. Share it + * between them + * + * @author Geneviève Bastien + */ +public class DataDrivenXYDataProvider extends AbstractTmfTraceDataProvider + implements ITmfTreeXYDataProvider<ITmfTreeDataModel> { + + /** + * Data provider ID + */ + public static final String ID = "org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlXYDataProvider"; //$NON-NLS-1$ + + private static final String TITLE = Objects.requireNonNull(Messages.XmlDataProvider_DefaultXYTitle); + private static final AtomicLong ENTRY_IDS = new AtomicLong(); + + /** + * The type of XY display + */ + public enum DisplayType { + /** Displays absolute value */ + ABSOLUTE, + /** Displays the difference between current and previous value */ + DELTA + } + + /** + * Remember the unique mappings of state system and quark to entry ID. + */ + private final Table<ITmfStateSystem, Integer, Long> fBaseQuarkToId = HashBasedTable.create(); + private final Map<Long, DisplayElement> fIDToDisplayQuark = new HashMap<>(); + private final Map<Long, String> fIdToTitle = new HashMap<>(); + private final IdGetter fIdGenerator = (ss, quark) -> fBaseQuarkToId.row(ss).computeIfAbsent(quark, s -> ENTRY_IDS.getAndIncrement()); + private final QuarkCallback fQuarkCallback = (id, ss, quark, displayType) -> fIDToDisplayQuark.put(id, new DisplayElement(ss, quark, displayType)); + + private final List<ITmfStateSystem> fSs; + private final List<DataDrivenOutputEntry> fEntries; + private final String fId; + + private @Nullable TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> fCached; + + private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock(false); + + private static class DisplayElement { + private final ITmfStateSystem fStateSystem; + private final int fQuark; + private final DisplayType fDisplayType; + + public DisplayElement(ITmfStateSystem stateSystem, int quark, DisplayType displayType) { + fStateSystem = stateSystem; + fQuark = quark; + fDisplayType = displayType; + } + } + + /** + * Constructor + * + * @param trace + * The trace this data provider is for + * @param stateSystems + * The list of state systems to build it for + * @param entries + * The entries + * @param id + * The ID of the data provider + */ + public DataDrivenXYDataProvider(ITmfTrace trace, List<ITmfStateSystem> stateSystems, List<DataDrivenOutputEntry> entries, @Nullable String id) { + super(trace); + fSs = stateSystems; + fEntries = entries; + fId = (id == null) ? ID : id; + } + + @Override + @Deprecated + public TmfModelResponse<ITmfXyModel> fetchXY(TimeQueryFilter filter, @Nullable IProgressMonitor monitor) { + return fetchXY(FetchParametersUtils.timeQueryToMap(filter), monitor); + } + + @Override + public TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) { + TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(fetchParameters); + if (filter == null) { + return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS); + } + long[] xValues = filter.getTimesRequested(); + + filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters); + if (filter == null) { + return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyMap(), true); + } + + Map<DisplayElement, IYModel> map = initSeries(filter); + if (map.isEmpty()) { + return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyMap(), true); + } + + ITmfStateSystem ss = null; + for (DisplayElement de : map.keySet()) { + ss = de.fStateSystem; + } + if (ss == null) { + return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyMap(), true); + } + + long currentEnd = ss.getCurrentEndTime(); + + try { + for (int i = 0; i < xValues.length; i++) { + if (monitor != null && monitor.isCanceled()) { + return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED); + } + long time = xValues[i]; + if (time > currentEnd) { + break; + } else if (ss.getStartTime() <= time) { + List<@NonNull ITmfStateInterval> full = ss.queryFullState(time); + for (Entry<DisplayElement, IYModel> series : map.entrySet()) { + int attributeQuark = series.getKey().fQuark; + if (attributeQuark >= 0 && attributeQuark < full.size()) { + Object value = full.get(attributeQuark).getValue(); + series.getValue().getData()[i] = extractValue(value); + } + } + } + } + // Update the series value if delta is requested + for (Entry<DisplayElement, IYModel> series : map.entrySet()) { + if (series.getKey().fDisplayType.equals(DisplayType.DELTA)) { + getSeriesDelta(series.getValue().getData()); + } + } + } catch (StateSystemDisposedException e) { + return TmfXyResponseFactory.createFailedResponse(e.getMessage()); + } + + boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd; + return TmfXyResponseFactory.create(TITLE, xValues, Maps.uniqueIndex(map.values(), value -> Long.toString(value.getId())), complete); + } + + private static void getSeriesDelta(double[] data) { + double prevData = data[0]; + data[0] = 0; + for (int i = 1; i < data.length; i++) { + double current = data[i]; + // Update value by subtracting previous value + data[i] = current - prevData; + prevData = current; + } + data[0] = data[1]; + } + + private Map<DisplayElement, IYModel> initSeries(TimeQueryFilter filter) { + if (!(filter instanceof SelectionTimeQueryFilter)) { + return Collections.emptyMap(); + } + fLock.readLock().lock(); + try { + Map<DisplayElement, IYModel> map = new HashMap<>(); + int length = filter.getTimesRequested().length; + for (Long id : ((SelectionTimeQueryFilter) filter).getSelectedItems()) { + DisplayElement displayElement = fIDToDisplayQuark.get(id); + if (displayElement != null) { + String name = String.valueOf(fIdToTitle.get(id)); + map.put(displayElement, new YModel(id, name, new double[length])); + } + } + return map; + } finally { + fLock.readLock().unlock(); + } + } + + private static double extractValue(@Nullable Object val) { + if (val instanceof Number) { + return ((Number) val).doubleValue(); + } + return 0; + } + + @Override + @Deprecated + public TmfModelResponse<List<ITmfTreeDataModel>> fetchTree(TimeQueryFilter filter, @Nullable IProgressMonitor monitor) { + Map<String, Object> parameters = FetchParametersUtils.timeQueryToMap(filter); + TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> response = fetchTree(parameters, monitor); + TmfTreeModel<ITmfTreeDataModel> model = response.getModel(); + List<ITmfTreeDataModel> treeModel = null; + if (model != null) { + treeModel = model.getEntries(); + } + return new TmfModelResponse<>(treeModel, response.getStatus(), response.getStatusMessage()); + } + + @Override + public TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) { + fLock.readLock().lock(); + try { + if (fCached != null) { + return fCached; + } + } finally { + fLock.readLock().unlock(); + } + List<ITmfTreeDataModel> entryList = new ArrayList<>(); + boolean isComplete = true; + + String traceName = String.valueOf(getTrace().getName()); + fLock.writeLock().lock(); + try { + for (ITmfStateSystem ss : fSs) { + isComplete &= ss.waitUntilBuilt(0); + /* Don't query empty state system */ + if (ss.getNbAttributes() > 0 && ss.getStartTime() != Long.MIN_VALUE) { + long start = ss.getStartTime(); + long end = ss.getCurrentEndTime(); + long id = fBaseQuarkToId.row(ss).computeIfAbsent(ITmfStateSystem.ROOT_ATTRIBUTE, s -> ENTRY_IDS.getAndIncrement()); + TimeGraphEntryModel ssEntry = new TimeGraphEntryModel(id, -1, traceName, start, end); + entryList.add(ssEntry); + + for (DataDrivenOutputEntry entry : fEntries) { + entryList.addAll(entry.buildEntries(ss, ssEntry.getId(), getTrace(), -1, StringUtils.EMPTY, end, fIdGenerator, fQuarkCallback)); + } + } + } + fIdToTitle.clear(); + entryList.forEach(e -> fIdToTitle.put(e.getId(), e.getName())); + if (isComplete) { + TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> tmfModelResponse = new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED); + fCached = tmfModelResponse; + return tmfModelResponse; + } + return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING); + } finally { + fLock.writeLock().unlock(); + } + } + + @Override + public String getId() { + return fId; + } + +} diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenXYProviderFactory.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenXYProviderFactory.java new file mode 100644 index 0000000000..67b6e60ac1 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/DataDrivenXYProviderFactory.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2019 École Polytechnique de Montréal + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.IDataDrivenRuntimeObject; +import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; +import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; +import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel; +import org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider; +import org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems; +import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; +import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; + +import com.google.common.collect.Iterables; + +/** + * Data provider factory for XY views + * + * @author Geneviève Bastien + */ +public class DataDrivenXYProviderFactory implements IDataDrivenRuntimeObject { + + private final List<DataDrivenOutputEntry> fEntries; + private final Set<String> fAnalysisIds; + + /** + * Constructor + * + * @param entries + * The list of entries + * @param analysisIds + * The IDs of the analysis this view applies to + */ + public DataDrivenXYProviderFactory(List<DataDrivenOutputEntry> entries, Set<String> analysisIds) { + fEntries = entries; + fAnalysisIds = analysisIds; + } + + /** + * Create an XY data provider for a trace + * + * @param trace + * The trace for which to create the data provider + * @return The XY data provider or <code>null</code> if no such provider is + * available for that trace + */ + public @Nullable ITmfTreeXYDataProvider<ITmfTreeDataModel> create(ITmfTrace trace) { + + Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>(); + List<ITmfStateSystem> sss = new ArrayList<>(); + if (fAnalysisIds.isEmpty()) { + /* + * No analysis specified, take all state system analysis modules + */ + Iterables.addAll(stateSystemModules, TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class)); + } else { + for (String moduleId : fAnalysisIds) { + // Get the module for the current trace only. The caller will + // take care of + // generating composite providers with experiments + IAnalysisModule module = trace.getAnalysisModule(moduleId); + if (module instanceof ITmfAnalysisModuleWithStateSystems) { + stateSystemModules.add((ITmfAnalysisModuleWithStateSystems) module); + } + } + } + + for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) { + if (module.schedule().isOK() && module.waitForInitialization()) { + module.getStateSystems().forEach(sss::add); + } + } + return (sss.isEmpty() ? null : new DataDrivenXYDataProvider(trace, sss, fEntries, null)); + } + +} diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/XmlDataProviderManager.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/XmlDataProviderManager.java index 9da8a08ab7..12b601a9ec 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/XmlDataProviderManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/output/XmlDataProviderManager.java @@ -11,18 +11,18 @@ package org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; -import java.util.Set; +import java.util.Map; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlXYViewCu; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlXYDataProvider; import org.eclipse.tracecompass.internal.tmf.core.model.timegraph.TmfTimeGraphCompositeDataProvider; import org.eclipse.tracecompass.internal.tmf.core.model.xy.TmfTreeXYCompositeDataProvider; -import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; -import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlUtils; import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider; import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel; import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel; @@ -52,6 +52,8 @@ public class XmlDataProviderManager { private static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ private final Table<ITmfTrace, String, ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel>> fXyProviders = HashBasedTable.create(); private final Table<ITmfTrace, String, ITimeGraphDataProvider<@NonNull TimeGraphEntryModel>> fTimeGraphProviders = HashBasedTable.create(); + private final Map<String, @Nullable DataDrivenTimeGraphProviderFactory> fTimeGraphFactories = new HashMap<>(); + private final Map<String, @Nullable DataDrivenXYProviderFactory> fXYFactories = new HashMap<>(); /** * Get the instance of the manager @@ -69,8 +71,6 @@ public class XmlDataProviderManager { /** * Dispose the singleton instance if it exists - * - * @since 2.5 */ public static synchronized void dispose() { XmlDataProviderManager manager = INSTANCE; @@ -90,15 +90,42 @@ public class XmlDataProviderManager { } /** - * Create (if necessary) and get the {@link XmlXYDataProvider} for the specified - * trace and viewElement. + * Create (if necessary) and get the {@link DataDrivenXYProviderFactory} for + * the specified trace and viewElement. + * + * @param viewElement + * the XML XY view element for which we are querying a provider + * @return the unique instance of an XY provider for the queried parameters + */ + public synchronized @Nullable DataDrivenXYProviderFactory getXyProviderFactory(Element viewElement) { + if (!viewElement.hasAttribute(ID_ATTRIBUTE)) { + return null; + } + String viewId = viewElement.getAttribute(ID_ATTRIBUTE); + // Factory is nullable, so make sure the key exist and return the + // factory that can be null + if (fXYFactories.containsKey(viewId)) { + return fXYFactories.get(viewId); + } + // Create with the trace or experiment first + DataDrivenXYProviderFactory factory = null; + TmfXmlXYViewCu tgViewCu = TmfXmlXYViewCu.compile(new AnalysisCompilationData(), viewElement); + if (tgViewCu != null) { + factory = tgViewCu.generate(); + } + fXYFactories.put(viewId, factory); + return factory; + } + + /** + * Create (if necessary) and get the {@link ITmfTreeXYDataProvider} for the + * specified trace and viewElement. * * @param trace * trace for which we are querying a provider * @param viewElement - * the XML XY view for which we are querying a provider + * the XML XY view element for which we are querying a provider * @return the unique instance of an XY provider for the queried parameters - * @since 3.0 */ public synchronized @Nullable ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> getXyProvider(ITmfTrace trace, Element viewElement) { if (!viewElement.hasAttribute(ID_ATTRIBUTE)) { @@ -111,28 +138,62 @@ public class XmlDataProviderManager { } if (Iterables.any(TmfTraceManager.getInstance().getOpenedTraces(), opened -> TmfTraceManager.getTraceSetWithExperiment(opened).contains(trace))) { - /* if this trace or an experiment containing this trace is opened */ - Collection<ITmfTrace> traces = TmfTraceManager.getTraceSet(trace); - if (traces.size() == 1) { - Set<@NonNull String> analysisIds = TmfXmlUtils.getViewAnalysisIds(viewElement); - Element entry = TmfXmlUtils.getChildElements(viewElement, TmfXmlStrings.ENTRY_ELEMENT).get(0); - provider = XmlXYDataProvider.create(trace, analysisIds, entry); - } else { - provider = generateExperimentProviderXy(traces, viewElement); - } - if (provider != null) { - fXyProviders.put(trace, viewId, provider); + DataDrivenXYProviderFactory xyFactory = getXyProviderFactory(viewElement); + // Create with the trace or experiment first + if (xyFactory != null) { + return createXYProvider(trace, viewId, xyFactory); } + + } + return null; + } + + /** + * Get the XY provider with a certain ID for a trace + * + * @param trace + * The trace to get the provider for + * @param providerId + * The ID of the provider + * @return The XY data provider + */ + public synchronized @Nullable ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> getXyProvider(ITmfTrace trace, String providerId) { + ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> provider = fXyProviders.get(trace, providerId); + if (provider != null) { return provider; } + DataDrivenXYProviderFactory factory = fXYFactories.get(providerId); + if (factory != null) { + return createXYProvider(trace, providerId, factory); + } return null; } - private @Nullable ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> generateExperimentProviderXy(Collection<@NonNull ITmfTrace> traces, Element viewElement) { + private @Nullable ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> createXYProvider(ITmfTrace trace, String providerId, DataDrivenXYProviderFactory xyFactory) { + ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> provider = xyFactory.create(trace); + + if (provider == null) { + // Otherwise, see if it's an experiment and create a composite if + // that's the case + Collection<ITmfTrace> traces = TmfTraceManager.getTraceSet(trace); + if (traces.size() > 1) { + // Try creating a composite only if there are many traces, + // otherwise, the previous call to create should have returned + // the data provider + provider = generateExperimentProviderXy(traces, providerId); + } + } + if (provider != null) { + fXyProviders.put(trace, providerId, provider); + } + return provider; + } + + private @Nullable ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> generateExperimentProviderXy(Collection<@NonNull ITmfTrace> traces, String providerId) { List<@NonNull ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel>> providers = new ArrayList<>(); for (ITmfTrace child : traces) { - ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> childProvider = getXyProvider(child, viewElement); + ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> childProvider = getXyProvider(child, providerId); if (childProvider != null) { providers.add(childProvider); } @@ -146,15 +207,46 @@ public class XmlDataProviderManager { } /** - * Create (if necessary) and get the {@link XmlXYDataProvider} for the specified - * trace and viewElement. + * Create (if necessary) and get the + * {@link DataDrivenTimeGraphProviderFactory} from the viewElement. + * + * @param viewElement + * the XML time graph view element for which we are querying a + * provider + * @return the unique instance of a time graph provider for the queried + * parameters + */ + public synchronized @Nullable DataDrivenTimeGraphProviderFactory getTimeGraphProviderFactory(Element viewElement) { + if (!viewElement.hasAttribute(ID_ATTRIBUTE)) { + return null; + } + String viewId = viewElement.getAttribute(ID_ATTRIBUTE); + // Factory is nullable, so make sure the key exist and return the + // factory that can be null + if (fTimeGraphFactories.containsKey(viewId)) { + return fTimeGraphFactories.get(viewId); + } + // Create with the trace or experiment first + DataDrivenTimeGraphProviderFactory factory = null; + TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement); + if (tgViewCu != null) { + factory = tgViewCu.generate(); + } + fTimeGraphFactories.put(viewId, factory); + return factory; + } + + /** + * Create (if necessary) and get the time graph data provider for the + * specified trace and viewElement. * * @param trace * trace for which we are querying a provider * @param viewElement - * the XML XY view for which we are querying a provider - * @return the unique instance of an XY provider for the queried parameters - * @since 3.0 + * the XML time graph view element for which we are querying a + * provider + * @return the unique instance of a time graph provider for the queried + * parameters */ public synchronized @Nullable ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> getTimeGraphProvider(ITmfTrace trace, Element viewElement) { if (!viewElement.hasAttribute(ID_ATTRIBUTE)) { @@ -216,7 +308,6 @@ public class XmlDataProviderManager { * * @param signal * The incoming signal - * @since 2.5 */ @TmfSignalHandler public synchronized void traceClosed(final TmfTraceClosedSignal signal) { diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java index 8ec1242968..84d61428b2 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java @@ -14,6 +14,7 @@ import java.io.ObjectOutputStream; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.datastore.core.interval.IHTIntervalReader; @@ -48,7 +49,7 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { private final long fStart; private final long fEnd; private final @NonNull String fSegmentName; - private transient @NonNull Map<@NonNull String, @NonNull ITmfStateValue> fContent; + private transient @NonNull Map<@NonNull String, @NonNull Object> fContent; /** * The reader for this segment class @@ -62,30 +63,29 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { String segmentName = buffer.getString(); int contentSize = buffer.getInt(); - final Map<@NonNull String, @NonNull ITmfStateValue> content = new HashMap<>(); + final Map<@NonNull String, @NonNull Object> content = new HashMap<>(); for (int i = 0; i < contentSize; i++) { String name = buffer.getString().intern(); Byte type = buffer.get(); - ITmfStateValue value; + Object value; switch (type) { - case TYPE_NULL: - value = TmfStateValue.nullValue(); - break; case TYPE_INTEGER: - value = TmfStateValue.newValueInt(buffer.getInt()); + value = buffer.getInt(); break; case TYPE_LONG: - value = TmfStateValue.newValueLong(buffer.getLong()); + value = buffer.getLong(); break; case TYPE_STRING: - value = TmfStateValue.newValueString(buffer.getString().intern()); + value = buffer.getString().intern(); break; default: - value = TmfStateValue.nullValue(); - Activator.logError("Read segment failed : Invalid data, value will be set to null"); //$NON-NLS-1$ + value = null; + Activator.logError("Read segment failed : Invalid data, value will be ignored"); //$NON-NLS-1$ + } + if (value != null) { + content.put(name, value); } - content.put(name, value); } return new TmfXmlPatternSegment(start, end, segmentName, content); }; @@ -97,14 +97,12 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { * Start time of the pattern segment * @param end * End time of the pattern segment - * @param scale - * Scale of the pattern segment * @param segmentName * Name of the pattern segment * @param fields * Fields of the pattern segment */ - public TmfXmlPatternSegment(long start, long end, String segmentName, @NonNull Map<@NonNull String, @NonNull ITmfStateValue> fields) { + public TmfXmlPatternSegment(long start, long end, String segmentName, @NonNull Map<@NonNull String, @NonNull Object> fields) { fStart = start; fEnd = end; fSegmentName = String.valueOf(segmentName); @@ -117,7 +115,7 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { * @return The content */ @Override - public Map<@NonNull String, @NonNull ITmfStateValue> getContent() { + public Map<@NonNull String, @NonNull Object> getContent() { return fContent; } @@ -173,23 +171,23 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { buffer.putInt(fContent.size()); // Write the fields - for (Map.Entry<String, ITmfStateValue> entry : fContent.entrySet()) { + for (Map.Entry<String, Object> entry : fContent.entrySet()) { buffer.putString(entry.getKey()); - final ITmfStateValue value = entry.getValue(); - final byte type = getByteFromType(value.getType()); + final Object value = entry.getValue(); + final byte type = getByteFromObject(value); buffer.put(type); switch (type) { case TYPE_NULL: break; case TYPE_INTEGER: - buffer.putInt(value.unboxInt()); + buffer.putInt((Integer) value); break; case TYPE_LONG: - buffer.putLong(value.unboxLong()); + buffer.putLong((Long) value); break; case TYPE_STRING: - final @NonNull String string = value.unboxStr(); - buffer.putString(string); + final String string = (String) value; + buffer.putString(Objects.requireNonNull(string)); break; default: Activator.logError("Write object failed : Invalid data"); //$NON-NLS-1$ @@ -200,10 +198,10 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { @Override public int getSizeOnDisk() { int size = 2 * Long.BYTES + Integer.BYTES + SafeByteBufferFactory.getStringSizeInBuffer(fSegmentName) + Integer.BYTES; - for (Map.Entry<String, ITmfStateValue> entry : fContent.entrySet()) { + for (Map.Entry<String, Object> entry : fContent.entrySet()) { size += SafeByteBufferFactory.getStringSizeInBuffer(entry.getKey()); - final ITmfStateValue value = entry.getValue(); - final byte type = getByteFromType(value.getType()); + final Object value = entry.getValue(); + final byte type = getByteFromObject(value); size += Byte.BYTES; switch (type) { case TYPE_NULL: @@ -215,8 +213,8 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { size += Long.BYTES; break; case TYPE_STRING: - final @NonNull String string = value.unboxStr(); - size += SafeByteBufferFactory.getStringSizeInBuffer(string); + final String string = (String) value; + size += SafeByteBufferFactory.getStringSizeInBuffer(Objects.requireNonNull(string)); break; default: Activator.logError("get segment size on disk failed : Invalid data"); //$NON-NLS-1$ @@ -232,23 +230,23 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { out.writeInt(fContent.size()); // Write the fields - for (Map.Entry<String, ITmfStateValue> entry : fContent.entrySet()) { + for (Map.Entry<String, Object> entry : fContent.entrySet()) { out.writeInt(entry.getKey().length()); out.writeBytes(entry.getKey()); - final ITmfStateValue value = entry.getValue(); - final byte type = getByteFromType(value.getType()); + final Object value = entry.getValue(); + final byte type = getByteFromObject(value); out.writeByte(type); switch (type) { case TYPE_NULL: break; case TYPE_INTEGER: - out.writeInt(value.unboxInt()); + out.writeInt((Integer) value); break; case TYPE_LONG: - out.writeLong(value.unboxLong()); + out.writeLong((Long) value); break; case TYPE_STRING: - final @NonNull String string = value.unboxStr(); + final String string = (String) value; out.writeInt(string.length()); out.writeBytes(string); break; @@ -262,7 +260,7 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { in.defaultReadObject(); int contentSize = in.readInt(); - final Map<@NonNull String, @NonNull ITmfStateValue> content = new HashMap<>(); + final Map<@NonNull String, @NonNull Object> content = new HashMap<>(); for (int i = 0; i < contentSize; i++) { int length = in.readInt(); byte[] bytes = new byte[length]; @@ -299,21 +297,20 @@ public class TmfXmlPatternSegment implements INamedSegment, IContentSegment { * Here we determine how state values "types" are written in the 8-bit field * that indicates the value type in the file. */ - private static byte getByteFromType(ITmfStateValue.Type type) { - switch (type) { - case NULL: + private static byte getByteFromObject(Object value) { + if (value == null) { return TYPE_NULL; - case INTEGER: + } + if (value instanceof Integer) { return TYPE_INTEGER; - case STRING: - return TYPE_STRING; - case LONG: + } + if (value instanceof Long) { return TYPE_LONG; - case DOUBLE: - case CUSTOM: - default: - /* Should not happen if the switch is fully covered */ - throw new IllegalStateException("Data type " + type + " not supported"); //$NON-NLS-1$ //$NON-NLS-2$ } + if (value instanceof String) { + return TYPE_STRING; + } + /* Should not happen, only the previous types are supported */ + throw new IllegalStateException("Data type " + value.getClass() + " not supported"); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/swtbot/tests/latency/PatternScatterChartViewTest.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/swtbot/tests/latency/PatternScatterChartViewTest.java index 1c910dd5d9..ea375e225b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/swtbot/tests/latency/PatternScatterChartViewTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/swtbot/tests/latency/PatternScatterChartViewTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 Ericsson + * Copyright (c) 2016, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -14,15 +14,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.matchers.WidgetOfType; -import org.eclipse.swtbot.swt.finder.results.Result; import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternScatterGraphView; @@ -30,9 +24,6 @@ import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer; -import org.eclipse.tracecompass.tmf.ui.views.TmfChartView; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IViewReference; import org.junit.Test; import org.junit.runner.RunWith; import org.swtchart.Chart; @@ -52,45 +43,20 @@ public class PatternScatterChartViewTest extends PatternLatencyViewTestBase { private static final String VIEW_TITLE = "Latency vs Time"; private Chart fScatterChart; - private TmfXYChartViewer getChartViewer() throws NoSuchMethodException, SecurityException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException { + private TmfXYChartViewer getChartViewer() { SWTBotView viewBot = fBot.viewById(VIEW_ID); - final IViewReference viewReference = viewBot.getViewReference(); - IViewPart viewPart = UIThreadRunnable.syncExec(new Result<IViewPart>() { - @Override - public IViewPart run() { - return viewReference.getView(true); - } - }); - assertNotNull(viewPart); - assertTrue("Could not instanciate view", viewPart instanceof PatternScatterGraphView); - TmfChartView chartView = (TmfChartView) viewPart; - Method viewer = TmfChartView.class.getDeclaredMethod("getChartViewer"); - viewer.setAccessible(true); - TmfXYChartViewer chartViewer = (TmfXYChartViewer) viewer.invoke(chartView); - - fScatterChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class)); - assertNotNull(fScatterChart); + PatternScatterGraphView viewPart = (PatternScatterGraphView) viewBot.getViewReference().getView(true); + TmfXYChartViewer chartViewer = viewPart.getChartViewer(); + fScatterChart = chartViewer.getSwtChart(); return chartViewer; } /** * Test the pattern latency scatter graph. This method test if the chart has one * series and the series has data - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ @Test - public void testWithTrace() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public void testWithTrace() { // Get the chart viewer and wait for the view to be ready WaitUtils.waitForJobs(); diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/preferences/XMLAnalysesManagerPreferencePage.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/preferences/XMLAnalysesManagerPreferencePage.java index 9d64589bbd..08bd763903 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/preferences/XMLAnalysesManagerPreferencePage.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/preferences/XMLAnalysesManagerPreferencePage.java @@ -185,6 +185,7 @@ public class XMLAnalysesManagerPreferencePage extends PreferencePage implements fAnalysesTable.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java index 4f003717ea..f40eb3ae57 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java @@ -26,7 +26,7 @@ import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphEntryModel; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntryModel; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlUtils; import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphEntryModel; @@ -96,7 +96,7 @@ public class XmlPresentationProvider extends TimeGraphPresentationProvider { int value = tcEvent.getValue(); ITimeGraphEntryModel model = entry.getModel(); - if (model instanceof DataDrivenTimeGraphEntryModel) { + if (model instanceof DataDrivenOutputEntryModel) { // Draw state only if state is already known Integer index = stateIndex.get(value); if (index != null) { @@ -117,7 +117,7 @@ public class XmlPresentationProvider extends TimeGraphPresentationProvider { if (event instanceof TimeEvent && ((TimeEvent) event).hasValue()) { TimeEvent tcEvent = (TimeEvent) event; - DataDrivenTimeGraphEntryModel model = (DataDrivenTimeGraphEntryModel) ((TimeGraphEntry) event.getEntry()).getModel(); + DataDrivenOutputEntryModel model = (DataDrivenOutputEntryModel) ((TimeGraphEntry) event.getEntry()).getModel(); int value = tcEvent.getValue(); if (model.getDisplayQuark() >= 0) { @@ -156,7 +156,7 @@ public class XmlPresentationProvider extends TimeGraphPresentationProvider { @Override public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) { // Is there text to show - DataDrivenTimeGraphEntryModel entry = (DataDrivenTimeGraphEntryModel) ((TimeGraphEntry) event.getEntry()).getModel(); + DataDrivenOutputEntryModel entry = (DataDrivenOutputEntryModel) ((TimeGraphEntry) event.getEntry()).getModel(); if (!entry.showText()) { return; } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java index 768f2e600f..d9faa93e9f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java @@ -24,8 +24,8 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntryModel; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphDataProvider; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphEntryModel; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.XmlDataProviderManager; import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator; import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlViewInfo; @@ -82,10 +82,20 @@ public class XmlTimeGraphView extends BaseDataProviderTimeGraphView { private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - private static final Comparator<DataDrivenTimeGraphEntryModel> XML_ENTRY_COMPARATOR = Comparator - .comparing(DataDrivenTimeGraphEntryModel::getName).thenComparingLong(DataDrivenTimeGraphEntryModel::getStartTime); - - private static final Comparator<ITimeGraphEntry> ENTRY_COMPARATOR = Comparator.comparing(x -> (DataDrivenTimeGraphEntryModel) ((TimeGraphEntry) x).getModel(), XML_ENTRY_COMPARATOR); + private static final Comparator<TimeGraphEntryModel> XML_ENTRY_COMPARATOR = ((TimeGraphEntryModel obj1, TimeGraphEntryModel obj2) -> { + try { + return Comparator + .comparing((TimeGraphEntryModel obj) -> Long.decode(obj.getName())) + .thenComparingLong(TimeGraphEntryModel::getStartTime) + .compare(obj1, obj2); + } catch (NumberFormatException nfe) { + return Comparator + .comparing(TimeGraphEntryModel::getName) + .thenComparingLong(TimeGraphEntryModel::getStartTime) + .compare(obj1, obj2); + } + }); + private static final Comparator<ITimeGraphEntry> ENTRY_COMPARATOR = Comparator.comparing(x -> (TimeGraphEntryModel) ((TimeGraphEntry) x).getModel(), XML_ENTRY_COMPARATOR); private final @NonNull XmlViewInfo fViewInfo = new XmlViewInfo(ID); private final Map<String, Integer> fStringValueMap = new HashMap<>(); @@ -188,8 +198,8 @@ public class XmlTimeGraphView extends BaseDataProviderTimeGraphView { } ITimeGraphEntryModel model = entry.getModel(); - if (model instanceof DataDrivenTimeGraphEntryModel) { - DataDrivenTimeGraphEntryModel xmlModel = (DataDrivenTimeGraphEntryModel) model; + if (model instanceof DataDrivenOutputEntryModel) { + DataDrivenOutputEntryModel xmlModel = (DataDrivenOutputEntryModel) model; if (DEFAULT_COLUMN_NAMES[columnIndex].equals(Messages.XmlTimeGraphView_ColumnId)) { return xmlModel.getXmlId(); } else if (DEFAULT_COLUMN_NAMES[columnIndex].equals(Messages.XmlTimeGraphView_ColumnParentId)) { diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlTreeViewer.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlTreeViewer.java index b8a08b5c3f..e5298a5f60 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlTreeViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlTreeViewer.java @@ -14,7 +14,7 @@ import java.util.Comparator; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlXYDataProvider; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYDataProvider; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.XmlDataProviderManager; import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlViewInfo; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; @@ -64,7 +64,7 @@ public class XmlTreeViewer extends AbstractSelectTreeViewer { * {@link XmlViewInfo} to manage the info on the class */ public XmlTreeViewer(Composite parent, XmlViewInfo viewInfo) { - super(parent, 1, XmlXYDataProvider.ID); + super(parent, 1, DataDrivenXYDataProvider.ID); fViewInfo = viewInfo; setLabelProvider(new XmlLabelProvider()); } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java index b25f9b9191..6b19ef9f93 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java @@ -14,7 +14,7 @@ package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.swt.widgets.Composite; -import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlXYDataProvider; +import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYDataProvider; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.XmlDataProviderManager; import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlViewInfo; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings; @@ -47,7 +47,7 @@ public class XmlXYViewer extends TmfFilteredXYChartViewer { * The view info object */ public XmlXYViewer(@Nullable Composite parent, TmfXYChartSettings settings, XmlViewInfo viewInfo) { - super(parent, settings, XmlXYDataProvider.ID); + super(parent, settings, DataDrivenXYDataProvider.ID); fViewInfo = viewInfo; } diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/Activator.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/Activator.java index 568b27977c..f53806ab5d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/Activator.java +++ b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/Activator.java @@ -43,6 +43,7 @@ public class Activator extends AbstractUIPlugin { * Constructor */ public Activator() { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/swtchart/SwtXYChartViewer.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/swtchart/SwtXYChartViewer.java index 1f7fc50dbd..d84dd7e2e8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/swtchart/SwtXYChartViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/swtchart/SwtXYChartViewer.java @@ -906,6 +906,7 @@ public abstract class SwtXYChartViewer extends TmfViewer implements IChartViewer private class ResizeEvent implements ControlListener { @Override public void controlMoved(@Nullable ControlEvent e) { + // Do nothing } @Override @@ -932,6 +933,7 @@ public abstract class SwtXYChartViewer extends TmfViewer implements IChartViewer @Override public void widgetDefaultSelected(@Nullable SelectionEvent e) { + // Do nothing } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java index 0a99abc763..4ce37afa61 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2017 Ericsson + * Copyright (c) 2009, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -992,7 +992,9 @@ public class TmfExperimentTest { } private static abstract class TestTrace extends TmfXmlTraceStubNs implements ITmfPropertiesProvider { - + public TestTrace(@NonNull String name) { + setName(name); + } } /** @@ -1007,7 +1009,7 @@ public class TmfExperimentTest { long offset = 1000; String clockOffset = "clock_offset"; - ITmfTrace t1 = new TestTrace() { + ITmfTrace t1 = new TestTrace("t1") { @Override public @NonNull String getHostId() { return hostId; @@ -1018,7 +1020,7 @@ public class TmfExperimentTest { } }; - ITmfTrace t2 = new TestTrace() { + ITmfTrace t2 = new TestTrace("t2") { @Override public @NonNull String getHostId() { return hostId; @@ -1028,7 +1030,6 @@ public class TmfExperimentTest { return ImmutableMap.of(clockOffset, String.valueOf(minOffset + offset)); } }; - TmfExperiment exp = new TmfExperimentStub(EXPERIMENT, new ITmfTrace[] { t1, t2 }, BLOCK_SIZE); try { @@ -1059,7 +1060,7 @@ public class TmfExperimentTest { ITmfTimestampTransform tt2 = TimestampTransformFactory.createLinear(2.0, -offset / 2); ITmfTimestampTransform tt3 = TimestampTransformFactory.createWithOffset(offset); - ITmfTrace t1 = new TestTrace() { + ITmfTrace t1 = new TestTrace("t1") { @Override public @NonNull String getHostId() { return hostId; @@ -1072,7 +1073,7 @@ public class TmfExperimentTest { }; t1.setTimestampTransform(tt1); - ITmfTrace t2 = new TestTrace() { + ITmfTrace t2 = new TestTrace("t2") { @Override public @NonNull String getHostId() { return hostId; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/stub/XmlStubTraceTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/stub/XmlStubTraceTest.java index f033f51cda..ac99567864 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/stub/XmlStubTraceTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/stub/XmlStubTraceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 École Polytechnique de Montréal + * Copyright (c) 2014, 2019 École Polytechnique de Montréal and others * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -13,6 +13,7 @@ package org.eclipse.tracecompass.tmf.core.tests.trace.stub; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -86,18 +87,19 @@ public class XmlStubTraceTest { */ @Test public void testValidate() { - fTestTrace = new TmfXmlTraceStubNs(); + ITmfTrace trace = new TmfXmlTraceStubNs(); File[] invalidFiles = TmfCoreTestPlugin.getAbsoluteFilePath(INVALID_PATH).toFile().listFiles(); assertTrue(invalidFiles.length > 0); for (File f : invalidFiles) { - assertTrue(!fTestTrace.validate(null, f.getAbsolutePath()).isOK()); + assertFalse(trace.validate(null, f.getAbsolutePath()).isOK()); } File[] validFiles = TmfCoreTestPlugin.getAbsoluteFilePath(VALID_PATH).toFile().listFiles(); assertTrue(validFiles.length > 0); for (File f : validFiles) { - assertTrue(fTestTrace.validate(null, f.getAbsolutePath()).isOK()); + assertTrue(trace.validate(null, f.getAbsolutePath()).isOK()); } + trace.dispose(); } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java index f37f1042f3..f43af433ee 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java @@ -106,6 +106,7 @@ public class TmfCollapseFilter implements ITmfFilterTreeNode { @Override public void setParent(ITmfFilterTreeNode parent) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomExtraFieldsAspect.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomExtraFieldsAspect.java index 6cf07b9f60..d68c46e82e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomExtraFieldsAspect.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomExtraFieldsAspect.java @@ -31,6 +31,7 @@ public class CustomExtraFieldsAspect implements ITmfEventAspect<String> { * Constructor */ public CustomExtraFieldsAspect() { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/TmfMemoryIndex.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/TmfMemoryIndex.java index 6f03ed2c5e..c27627b66a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/TmfMemoryIndex.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/TmfMemoryIndex.java @@ -101,5 +101,6 @@ public class TmfMemoryIndex implements ITmfCheckpointIndex, ICheckpointCollectio @Override public void delete() { + // Do nothing } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/TmfProjectNature.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/TmfProjectNature.java index c205cfdcc4..09474f8e5a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/TmfProjectNature.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/TmfProjectNature.java @@ -45,10 +45,12 @@ public class TmfProjectNature implements IProjectNature { @Override public void configure() throws CoreException { + // Do nothing } @Override public void deconfigure() throws CoreException { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java index 301ea9b96f..9caa74c9c2 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java @@ -84,7 +84,12 @@ public abstract class TmfEventProvider extends TmfComponent implements ITmfEvent private Timer fTimer; /** Current timer task */ - @NonNull private TimerTask fCurrentTask = new TimerTask() { @Override public void run() {} }; + @NonNull private TimerTask fCurrentTask = new TimerTask() { + @Override + public void run() { + // Do nothing + } + }; private boolean fIsTimerEnabled; diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TmfEventMatches.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TmfEventMatches.java index 8ad73ae5a4..4fe193d922 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TmfEventMatches.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TmfEventMatches.java @@ -49,7 +49,7 @@ public class TmfEventMatches implements IMatchProcessingUnit { @Override public void matchingEnded() { - + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java index 4865674933..5da7059de1 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java @@ -238,10 +238,12 @@ public abstract class CustomTraceDefinition { return new ErrorHandler() { @Override public void error(SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override public void warning(SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java index 5bed793176..c22083730c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java @@ -325,10 +325,12 @@ public class CustomXmlTrace extends TmfTrace implements ITmfPersistentlyIndexabl db.setErrorHandler(new ErrorHandler() { @Override public void error(final SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override public void warning(final SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java index f27a83bfac..1ddf274db8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java @@ -445,10 +445,12 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { db.setErrorHandler(new ErrorHandler() { @Override public void error(SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override public void warning(SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override @@ -626,10 +628,12 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { db.setErrorHandler(new ErrorHandler() { @Override public void error(SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override public void warning(SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/signal/TmfSignalThrottler.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/signal/TmfSignalThrottler.java index 4ef82e51c4..6a3cd30a58 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/signal/TmfSignalThrottler.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/signal/TmfSignalThrottler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 Ericsson + * Copyright (c) 2013, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -22,16 +22,18 @@ import org.eclipse.tracecompass.tmf.core.component.ITmfComponent; /** * "Buffer" between a TmfComponent and the signal manager. You can use this if * you want to throttle the amount of signals your component will send. - * + * <p> * It works by specifying a delay, then calling {@link #queue}. The signals will * only be really sent if no other call to {@link #queue} happens within $delay * milliseconds afterwards. This guarantees that only the *last* signal is * actually broadcasted. - * + * <p> * Note that this class does not discriminate for signal types, sources, or * whatever. If you want to throttle different signals in different ways, you * can use multiple signal throttlers in your component and call them * accordingly. + * <p> + * This throttler will broadcast the signal from a TimerThread. * * @author Alexandre Montplaisir */ @@ -67,6 +69,7 @@ public class TmfSignalThrottler { fCurrentTask = new TimerTask() { @Override public void run() { + // Do nothing } }; } @@ -107,12 +110,22 @@ public class TmfSignalThrottler { @Override public void run() { - if (fComponent != null) { - fComponent.broadcast(signal); - } else { - TmfSignalManager.dispatchSignal(signal); - } + dispatchSignal(signal); } } + /** + * Dispatch the signal + * + * @param signal + * the signal + * @since 5.0 + */ + protected void dispatchSignal(TmfSignal signal) { + if (fComponent != null) { + fComponent.broadcast(signal); + } else { + TmfSignalManager.dispatchSignal(signal); + } + } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfContext.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfContext.java index 3c29e816e4..f703a02150 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfContext.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfContext.java @@ -123,6 +123,7 @@ public class TmfContext implements ITmfContext { @Override public void dispose() { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java index 7cad040800..a4fb18b906 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2018 Ericsson and others + * Copyright (c) 2013, 2019 Ericsson and others * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.function.UnaryOperator; import java.util.stream.Collectors; @@ -35,6 +36,7 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.URIUtil; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -666,19 +668,19 @@ public final class TmfTraceManager { } /** - * Get a temporary directory based on a trace's name. We will create the + * Get a temporary directory based on a trace's path. We will create the * directory if it doesn't exist, so that it's ready to be used. */ private static String getTemporaryDir(ITmfTrace trace) { - String pathName = getTemporaryDirPath() + - File.separator + - trace.getName() + - File.separator; + String pathName = new Path(getTemporaryDirPath()) + .append(trace.getPath() != null ? trace.getPath() : trace.getName()) + .addTrailingSeparator() + .toOSString(); File dir = new File(pathName); if (!dir.exists()) { dir.mkdirs(); } - return pathName; + return Objects.requireNonNull(pathName); } /* diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/Activator.java b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/Activator.java index eb86223e19..c7075f2bdd 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/Activator.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/Activator.java @@ -55,6 +55,7 @@ public class Activator extends AbstractUIPlugin { * Constructor */ public Activator() { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/preferences/ControlPreferencePage.java b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/preferences/ControlPreferencePage.java index 5590ce85e0..cfbec08ab9 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/preferences/ControlPreferencePage.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/preferences/ControlPreferencePage.java @@ -49,6 +49,7 @@ public class ControlPreferencePage extends FieldEditorPreferencePage implements @Override public void init(IWorkbench workbench) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/RemoteFetchLogWizardRemotePage.java b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/RemoteFetchLogWizardRemotePage.java index afd25b628d..296047adda 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/RemoteFetchLogWizardRemotePage.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/RemoteFetchLogWizardRemotePage.java @@ -231,6 +231,7 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa @Override protected void updateWithFilePathSelection() { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/preferences/RemoteProfilesPreferencePage.java b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/preferences/RemoteProfilesPreferencePage.java index 2f947e45a7..da0c137ebd 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/preferences/RemoteProfilesPreferencePage.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/preferences/RemoteProfilesPreferencePage.java @@ -161,6 +161,7 @@ public class RemoteProfilesPreferencePage extends PreferencePage implements IWor * Constructor */ public RemoteProfilesPreferencePage() { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/META-INF/MANIFEST.MF b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/META-INF/MANIFEST.MF index a18be93741..2206393e44 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/META-INF/MANIFEST.MF +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/META-INF/MANIFEST.MF @@ -25,7 +25,7 @@ Import-Package: com.google.common.base, com.google.common.collect, com.google.common.primitives, com.google.gson, - org.apache.commons.lang.exception, + org.apache.commons.lang3.exception, org.apache.log4j, org.apache.log4j.varia, org.eclipse.swtbot.eclipse.finder, diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/ConditionHelpers.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/ConditionHelpers.java index 139f2bdfa8..4a481a00fe 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/ConditionHelpers.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/ConditionHelpers.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2016 Ericsson + * Copyright (c) 2013, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; import java.util.regex.Pattern; -import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.IWizardContainer; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotSwtChart.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotSwtChart.java index 0b2b2f3cdf..37b2480e05 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotSwtChart.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotSwtChart.java @@ -9,11 +9,16 @@ package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; + import org.eclipse.swtbot.swt.finder.SWTBot; import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; import org.eclipse.swtbot.swt.finder.matchers.WidgetOfType; import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl; import org.swtchart.Chart; +import org.swtchart.ISeries; /** * SWTBot class representing a SwtChart @@ -49,4 +54,33 @@ public class SWTBotSwtChart extends AbstractSWTBotControl<Chart> { public AbstractSWTBotControl<Chart> moveMouseToWidget() { return super.moveMouseToWidget(); } + + /** + * Returns the list of series + * + * @return the list of series + */ + public List<SWTBotSwtChartSeries> getSeries() { + List<SWTBotSwtChartSeries> list = new ArrayList<>(); + for (ISeries series : widget.getSeriesSet().getSeries()) { + list.add(new SWTBotSwtChartSeries(widget, series)); + } + return list; + } + + /** + * Returns the series with the specified id + * + * @param id + * the id + * @return the series + */ + public SWTBotSwtChartSeries getSeries(String id) { + AtomicReference<ISeries> series = new AtomicReference<>(); + SWTBotUtils.waitUntil(chart -> { + series.set(widget.getSeriesSet().getSeries(id)); + return series.get() != null; + }, widget, () -> "Timed out waiting for series " + id); + return new SWTBotSwtChartSeries(widget, series.get()); + } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotSwtChartSeries.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotSwtChartSeries.java new file mode 100644 index 0000000000..434b2d8070 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotSwtChartSeries.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2019 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared; + +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl; +import org.swtchart.Chart; +import org.swtchart.ISeries; +import org.swtchart.ISeries.SeriesType; + +/** + * SWTBot class representing a SwtChart series + * + * @author Patrick Tasse + */ +public class SWTBotSwtChartSeries extends AbstractSWTBotControl<Chart> { + + private final ISeries fSeries; + + /** + * Constructor + * + * @param chart + * the chart widget + * @param series + * the series + * @throws WidgetNotFoundException + * if the widget is <code>null</code> or widget has been + * disposed. + */ + public SWTBotSwtChartSeries(Chart chart, ISeries series) throws WidgetNotFoundException { + super(chart); + fSeries = series; + } + + /** + * Returns the series type + * + * @return the series type + */ + public SeriesType getType() { + return fSeries.getType(); + } + + /** + * Returns the series id + * + * @return the series id + */ + public String getSeriesId() { + return fSeries.getId(); + } +} diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/XYDataProviderBaseTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/XYDataProviderBaseTest.java index ef24f24695..af0cb604b4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/XYDataProviderBaseTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/XYDataProviderBaseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 Ericsson + * Copyright (c) 2017, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -14,8 +14,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; @@ -216,32 +214,17 @@ public abstract class XYDataProviderBaseTest { } /** - * Gets the ChartViewer from a IViewPart + * Gets the ChartViewer from a TmfChartView * - * @param viewSite + * @param viewPart * The IViewPart * @return The ChartViewer from the IViewPart - * - * @throws NoSuchMethodException - * Reflection exception should not happen - * @throws SecurityException - * Reflection exception should not happen - * @throws IllegalAccessException - * Reflection exception should not happen - * @throws IllegalArgumentException - * Reflection exception should not happen - * @throws InvocationTargetException - * Reflection exception should not happen */ - protected static TmfXYChartViewer getChartViewer(IViewPart viewSite) - throws NoSuchMethodException, SecurityException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException { - - TmfChartView chartView = (TmfChartView) viewSite; - Method viewer = TmfChartView.class.getDeclaredMethod("getChartViewer"); - viewer.setAccessible(true); - TmfXYChartViewer chartViewer = (TmfXYChartViewer) viewer.invoke(chartView); - return chartViewer; + protected static TmfXYChartViewer getChartViewer(IViewPart viewPart) { + if (viewPart instanceof TmfChartView) { + return ((TmfChartView) viewPart).getChartViewer(); + } + return null; } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java index ec8d2df6b0..fc1d48e0e0 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java @@ -42,9 +42,7 @@ import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils; import org.eclipse.tracecompass.tmf.ui.views.colors.ColorSetting; import org.eclipse.tracecompass.tmf.ui.views.colors.ColorSettingsManager; import org.eclipse.tracecompass.tmf.ui.views.colors.ColorsView; -import org.junit.After; import org.junit.AfterClass; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -183,37 +181,26 @@ public class ColorsViewTest { } braf.writeBytes(TRACE_END); } - } - - /** - * Open a trace in an editor - */ - @Before - public void beforeTest() { + /* Creating project and open the trace */ SWTBotUtils.createProject(PROJECT_NAME); SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); assertNotNull(treeItem); SWTBotUtils.openTrace(PROJECT_NAME, fFileLocation.getAbsolutePath(), XMLSTUB_ID); SWTBotUtils.openView(ColorsView.ID); + } /** - * Delete the file + * Delete the file and Close the editor */ @AfterClass public static void cleanUp() { fLogger.removeAllAppenders(); fFileLocation.delete(); - } - - /** - * Close the editor - */ - @After - public void tearDown() { fBot.closeAllEditors(); SWTBotUtils.deleteProject(PROJECT_NAME, fBot); SWTBotUtils.closeViewById(ColorsView.ID, fBot); + } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java index f2921e971a..ed56e28aba 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/TimeGraphViewTest.java @@ -141,6 +141,19 @@ public class TimeGraphViewTest { private static final String RESET_LOC = "reset"; private static final TmfTimeRange INITIAL_WINDOW_RANGE = new TmfTimeRange(TmfTimestamp.fromNanos(20), TmfTimestamp.fromNanos(100)); + /** + * Legend id key + */ + private static final String LEGEND_ENTRY_KEY = "legend.entry.key"; + + /** + * Hair entry id + */ + private static final String HAIR_ID = "HAIR"; + /** + * Laser entry id + */ + private static final String QUOTE_LASER_UNQUOTE = "\"LASER\""; private SWTBotView fViewBot; @@ -339,10 +352,10 @@ public class TimeGraphViewTest { SWTBotShell legendShell = fBot.shell(LEGEND_NAME); legendShell.activate(); SWTBot legendBot = legendShell.bot(); - assertFalse(legendBot.button(5).isEnabled()); - int defaultValue = legendBot.scale(5).getValue(); - legendBot.scale(5).setValue(100); - assertTrue(legendBot.button(5).isEnabled()); + assertFalse(legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) QUOTE_LASER_UNQUOTE).isEnabled()); + int defaultValue = legendBot.scaleWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).getValue(); + legendBot.scaleWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).setValue(100); + assertTrue(legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) QUOTE_LASER_UNQUOTE).isEnabled()); legendShell.bot().button(OK_BUTTON).click(); fBot.waitUntil(Conditions.shellCloses(legendShell)); resetTimeRange(); @@ -359,10 +372,10 @@ public class TimeGraphViewTest { fViewBot.toolbarButton(SHOW_LEGEND).click(); legendShell = fBot.shell(LEGEND_NAME); legendBot = legendShell.bot(); - assertTrue(legendBot.button(5).isEnabled()); - legendBot.button(5).click(); - assertEquals(defaultValue, legendBot.scale(5).getValue()); - assertFalse(legendBot.button(5).isEnabled()); + assertTrue(legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) QUOTE_LASER_UNQUOTE).isEnabled()); + legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) QUOTE_LASER_UNQUOTE).click(); + assertEquals(defaultValue, legendBot.scaleWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).getValue()); + assertFalse(legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) QUOTE_LASER_UNQUOTE).isEnabled()); legendBot.button(OK_BUTTON).click(); fBot.waitUntil(Conditions.shellCloses(legendShell)); resetTimeRange(); @@ -425,10 +438,10 @@ public class TimeGraphViewTest { SWTBotShell legendShell = fBot.shell(LEGEND_NAME); legendShell.activate(); SWTBot legendBot = legendShell.bot(); - assertFalse(legendBot.button(2).isEnabled()); - int defaultValue = legendBot.scale(2).getValue(); - legendBot.scale(2).setValue(25); - assertTrue(legendBot.button(2).isEnabled()); + assertFalse(legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) HAIR_ID).isEnabled()); + int defaultValue = legendBot.scaleWithId(LEGEND_ENTRY_KEY, HAIR_ID).getValue(); + legendBot.scaleWithId(LEGEND_ENTRY_KEY, HAIR_ID).setValue(25); + assertTrue(legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) HAIR_ID).isEnabled()); legendShell.bot().button(OK_BUTTON).click(); fBot.waitUntil(Conditions.shellCloses(legendShell)); resetTimeRange(); @@ -445,10 +458,10 @@ public class TimeGraphViewTest { fViewBot.toolbarButton(SHOW_LEGEND).click(); legendShell = fBot.shell(LEGEND_NAME); legendBot = legendShell.bot(); - assertTrue(legendBot.button(2).isEnabled()); - legendBot.button(2).click(); - assertEquals(defaultValue, legendBot.scale(2).getValue()); - assertFalse(legendBot.button(2).isEnabled()); + assertTrue(legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) HAIR_ID).isEnabled()); + legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) HAIR_ID).click(); + assertEquals(defaultValue, legendBot.scaleWithId(LEGEND_ENTRY_KEY, HAIR_ID).getValue()); + assertFalse(legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) HAIR_ID).isEnabled()); legendBot.button(OK_BUTTON).click(); fBot.waitUntil(Conditions.shellCloses(legendShell)); resetTimeRange(); @@ -498,7 +511,7 @@ public class TimeGraphViewTest { SWTBotShell legendShell = fBot.shell(LEGEND_NAME); legendShell.activate(); SWTBot legendBot = legendShell.bot(); - legendBot.scale(2).setValue(50); + legendBot.scaleWithId(LEGEND_ENTRY_KEY, HAIR_ID).setValue(50); legendShell.bot().button(OK_BUTTON).click(); fBot.waitUntil(Conditions.shellCloses(legendShell)); resetTimeRange(); @@ -519,7 +532,7 @@ public class TimeGraphViewTest { fViewBot.toolbarButton(SHOW_LEGEND).click(); legendShell = fBot.shell(LEGEND_NAME); legendBot = legendShell.bot(); - legendBot.button(2).click(); + legendBot.buttonWithId(LEGEND_ENTRY_KEY, (Object) HAIR_ID).click(); legendBot.button(OK_BUTTON).click(); fBot.waitUntil(Conditions.shellCloses(legendShell)); resetTimeRange(); @@ -585,6 +598,7 @@ public class TimeGraphViewTest { @Test public void testVerticalZoom() { resetTimeRange(); + int threshold = 10; SWTBotTimeGraph timegraph = fTimeGraph; Rectangle bounds = fBounds; @@ -597,6 +611,8 @@ public class TimeGraphViewTest { ImageHelper bigSmall = ImageHelper.grabImage(bounds); ImageHelper diff = ref.diff(bigSmall); + // 3% of the image + threshold = (int) (diff.getHistogram().size() * 0.03); List<RGB> colors = filter(diff.getHistogram(), threshold); assertEquals(colors.toString(), 1, colors.size()); @@ -728,7 +744,7 @@ public class TimeGraphViewTest { assertEquals(16, getVisibleItems(timegraph)); timegraph.getEntry(pg, "Hat1").select(); - fireKey(timegraph, true, SWT.CR); + fireKey(timegraph, true, SWT.CR); assertEquals(1, timegraph.selection().columnCount()); assertEquals("[Hat1]", timegraph.selection().get(0).toString()); assertEquals(16, getVisibleItems(timegraph)); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/XYChartViewTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/XYChartViewTest.java index b67245a60a..74bf07007f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/XYChartViewTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/views/XYChartViewTest.java @@ -11,9 +11,6 @@ package org.eclipse.tracecompass.tmf.ui.swtbot.tests.views; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.lang.reflect.Method; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Logger; @@ -44,7 +41,6 @@ import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotSwtChart; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer; import org.eclipse.tracecompass.tmf.ui.views.TmfChartView; -import org.eclipse.ui.IViewPart; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -128,8 +124,8 @@ public class XYChartViewTest { fViewBot = fBot.viewById(XYChartViewStub.ID); fViewBot.show(); - IViewPart viewSite = fViewBot.getViewReference().getView(true); - fXyViewer = getChartViewer(viewSite); + TmfChartView viewPart = (TmfChartView) fViewBot.getViewReference().getView(true); + fXyViewer = viewPart.getChartViewer(); // Wait till SWT chart is constructed fViewBot.bot().waitUntil(new DefaultCondition() { @@ -268,17 +264,6 @@ public class XYChartViewTest { // ------------------------------------------------------------------------ // Helper methods // ------------------------------------------------------------------------ - private static TmfXYChartViewer getChartViewer(IViewPart viewSite) { - try { - TmfChartView chartView = (TmfChartView) viewSite; - Method viewer = TmfChartView.class.getDeclaredMethod("getChartViewer"); - viewer.setAccessible(true); - return (TmfXYChartViewer) viewer.invoke(chartView); - } catch (Exception e) { - fail("Reflection exception " + e); - } - return null; - } private static void fireKeyInGraph(SWTBotSwtChart chart, char c, int... modifiers) { chart.setFocus(); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Activator.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Activator.java index c3c65f9f50..264e6d9a91 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Activator.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Activator.java @@ -72,6 +72,7 @@ public class Activator extends AbstractUIPlugin { * Constructor */ public Activator() { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/ITmfUIPreferences.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/ITmfUIPreferences.java index 677a27d6c3..542faf0c3c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/ITmfUIPreferences.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/ITmfUIPreferences.java @@ -51,4 +51,9 @@ public interface ITmfUIPreferences { * Preference for hiding the Many Entries Selected MessageDialog */ String HIDE_MANY_ENTRIES_SELECTED_TOGGLE = "HIDE_MANY_ENTRIES_SELECTED_TOGGLE"; //$NON-NLS-1$ + + /** + * Preference to use HTML Tooltips + */ + String USE_BROWSER_TOOLTIPS = "USE_HTML_TOOLTIPS"; //$NON-NLS-1$ } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java index 3f4a48c6d1..f8dc8bc787 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java @@ -350,23 +350,6 @@ public class Messages extends NLS { public static String TmfView_UnpinActionText; public static String TmfView_ResetScaleActionNameText; - public static String CallStackPresentationProvider_Process; - public static String CallStackPresentationProvider_Thread; - public static String CallStackView_FunctionColumn; - public static String CallStackView_PidTidColumn; - public static String CallStackView_DepthColumn; - public static String CallStackView_EntryTimeColumn; - public static String CallStackView_ExitTimeColumn; - public static String CallStackView_DurationColumn; - public static String CallStackView_ThreadColumn; - public static String CallStackView_StackInfoNotAvailable; - public static String CallStackView_SortByThreadName; - public static String CallStackView_SortByThreadId; - public static String CallStackView_SortByThreadTime; - - public static String CallStackView_ConfigureSymbolProvidersText; - public static String CallStackView_ConfigureSymbolProvidersTooltip; - public static String CopyToClipboardOperation_TaskName; public static String CopyToClipboardOperation_OutOfMemoryErrorTitle; public static String CopyToClipboardOperation_OutOfMemoryErrorMessage; @@ -389,6 +372,7 @@ public class Messages extends NLS { public static String TmfTracingPreferencePage_ConfirmDeletionSupplementaryFiles; public static String TmfTracingPreferencePage_AlwaysCloseOnResourceChange; public static String TmfTracingPreferencePage_HideManyEntriesSelectedWarning; + public static String TmfTracingPreferencePage_UseBrowserTooltips; static { // initialize resource bundle diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/commands/ExportToTextCommandHandler.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/commands/ExportToTextCommandHandler.java index 91b5dc7684..1590ed4355 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/commands/ExportToTextCommandHandler.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/commands/ExportToTextCommandHandler.java @@ -47,6 +47,7 @@ public class ExportToTextCommandHandler extends AbstractHandler { * Constructor */ public ExportToTextCommandHandler() { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java index 7bacae835f..958dd29afb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java @@ -104,7 +104,9 @@ public class ManageCustomParsersDialog extends Dialog { txtButton.setSelection(true); txtButton.addSelectionListener(new SelectionListener() { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } @Override public void widgetSelected(SelectionEvent e) { @@ -117,6 +119,7 @@ public class ManageCustomParsersDialog extends Dialog { xmlButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing } @Override @@ -129,7 +132,9 @@ public class ManageCustomParsersDialog extends Dialog { parserList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); parserList.addSelectionListener(new SelectionListener() { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } @Override public void widgetSelected(SelectionEvent e) { @@ -154,7 +159,9 @@ public class ManageCustomParsersDialog extends Dialog { newButton.setText(Messages.ManageCustomParsersDialog_NewButtonLabel); newButton.addSelectionListener(new SelectionListener() { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } @Override public void widgetSelected(SelectionEvent e) { @@ -179,7 +186,9 @@ public class ManageCustomParsersDialog extends Dialog { editButton.setEnabled(false); editButton.addSelectionListener(new SelectionListener() { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } @Override public void widgetSelected(SelectionEvent e) { @@ -209,7 +218,9 @@ public class ManageCustomParsersDialog extends Dialog { deleteButton.setEnabled(false); deleteButton.addSelectionListener(new SelectionListener() { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } @Override public void widgetSelected(SelectionEvent e) { @@ -240,7 +251,9 @@ public class ManageCustomParsersDialog extends Dialog { importButton.setText(Messages.ManageCustomParsersDialog_ImportButtonLabel); importButton.addSelectionListener(new SelectionListener() { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } @Override public void widgetSelected(SelectionEvent e) { @@ -279,7 +292,9 @@ public class ManageCustomParsersDialog extends Dialog { exportButton.setEnabled(false); exportButton.addSelectionListener(new SelectionListener() { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } @Override public void widgetSelected(SelectionEvent e) { diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties index dc7a4d18af..4a8a2c3192 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties @@ -347,24 +347,6 @@ TmfView_PinActionToolTipText=Pin View TmfView_PinToActionText=Pin to {0} TmfView_UnpinActionText=Unpin View -# org.eclipse.tracecompass.tmf.ui.views.callstack -CallStackPresentationProvider_Process=Process -CallStackPresentationProvider_Thread=Thread -CallStackView_FunctionColumn=Name -CallStackView_PidTidColumn=PID/TID -CallStackView_DepthColumn=Depth -CallStackView_EntryTimeColumn=Start time -CallStackView_ExitTimeColumn=End time -CallStackView_DurationColumn=Duration -CallStackView_ThreadColumn=Thread -CallStackView_StackInfoNotAvailable=Stack info not available -CallStackView_SortByThreadName=Sort threads by thread name -CallStackView_SortByThreadId=Sort threads by thread id -CallStackView_SortByThreadTime=Sort threads by start time - -CallStackView_ConfigureSymbolProvidersText=Configure symbol providers -CallStackView_ConfigureSymbolProvidersTooltip=Configure how the addresses are mapped to function names - CopyToClipboardOperation_TaskName=Copying to Clipboard CopyToClipboardOperation_OutOfMemoryErrorTitle=Out Of Memory Error CopyToClipboardOperation_OutOfMemoryErrorMessage=The full selection cannot be copied to the clipboard. Press OK to abort. @@ -387,3 +369,4 @@ TmfTracingPreferencePage_TraceRangeInProjectExplorer=Show trace time range in Pr TmfTracingPreferencePage_ConfirmDeletionSupplementaryFiles=Ask for confirmation before deleting supplementary files TmfTracingPreferencePage_AlwaysCloseOnResourceChange=Always close trace editors and delete supplementary files when resource is changed TmfTracingPreferencePage_HideManyEntriesSelectedWarning=Always hide the warning dialog when many entries are selected in a chart +TmfTracingPreferencePage_UseBrowserTooltips=Use browser based tooltips diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java index 76a738379d..183598f9b0 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java @@ -502,10 +502,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage { @Override public void dispose() { + // Do nothing } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // Do nothing } @Override @@ -1143,6 +1145,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { cardinalityCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing } @Override @@ -1487,6 +1490,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { tagCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java index bef4d84962..e7dbac45e6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java @@ -548,10 +548,12 @@ public class CustomXmlParserInputWizardPage extends WizardPage { @Override public void dispose() { + // Do nothing } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // Do nothing } @Override @@ -762,10 +764,12 @@ public class CustomXmlParserInputWizardPage extends WizardPage { db.setErrorHandler(new ErrorHandler() { @Override public void error(SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override public void warning(SAXParseException saxparseexception) throws SAXException { + // Do nothing } @Override @@ -941,6 +945,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { logEntryButton.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing } @Override @@ -974,6 +979,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { tagCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing } @Override @@ -1401,6 +1407,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { tagCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/preferences/PerspectivesPreferencePage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/preferences/PerspectivesPreferencePage.java index c81dd7398b..e80389a7c1 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/preferences/PerspectivesPreferencePage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/preferences/PerspectivesPreferencePage.java @@ -47,6 +47,7 @@ public class PerspectivesPreferencePage extends FieldEditorPreferencePage implem @Override public void init(IWorkbench workbench) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/preferences/TmfTracingPreferencePage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/preferences/TmfTracingPreferencePage.java index b590e5dd95..840a155e38 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/preferences/TmfTracingPreferencePage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/preferences/TmfTracingPreferencePage.java @@ -73,6 +73,10 @@ public class TmfTracingPreferencePage extends FieldEditorPreferencePage implemen BooleanFieldEditor treeXyWarning = new BooleanFieldEditor(ITmfUIPreferences.HIDE_MANY_ENTRIES_SELECTED_TOGGLE, Messages.TmfTracingPreferencePage_HideManyEntriesSelectedWarning, getFieldEditorParent()); addField(treeXyWarning); + + BooleanFieldEditor useBrowserTooltips = new BooleanFieldEditor(ITmfUIPreferences.USE_BROWSER_TOOLTIPS, + Messages.TmfTracingPreferencePage_UseBrowserTooltips, getFieldEditorParent()); + addField(useBrowserTooltips); } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java index f63145aeaa..c9ed9bd838 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java @@ -133,10 +133,12 @@ public class SelectSupplementaryResourcesDialog extends Dialog { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // Do nothing } @Override public void dispose() { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/DropAdapterAssistant.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/DropAdapterAssistant.java index 880cfdec92..638d0a13fe 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/DropAdapterAssistant.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/DropAdapterAssistant.java @@ -77,6 +77,7 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant { * Default constructor */ public DropAdapterAssistant() { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/TmfActionProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/TmfActionProvider.java index 0ddd7eb8ae..81f69c5550 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/TmfActionProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/TmfActionProvider.java @@ -43,6 +43,7 @@ public class TmfActionProvider extends CommonActionProvider { * Default constructor */ public TmfActionProvider() { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/TracePropertyTester.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/TracePropertyTester.java index 97072dd002..8244c69bbe 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/TracePropertyTester.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/TracePropertyTester.java @@ -47,6 +47,7 @@ public class TracePropertyTester extends PropertyTester { * Default constructor */ public TracePropertyTester() { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/importtrace/FileSystemObjectImportStructureProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/importtrace/FileSystemObjectImportStructureProvider.java index 3a33240b40..a491717c7d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/importtrace/FileSystemObjectImportStructureProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/importtrace/FileSystemObjectImportStructureProvider.java @@ -104,5 +104,6 @@ public class FileSystemObjectImportStructureProvider implements IImportStructure * Disposes of the resources associated with the provider. */ public void dispose() { + // Do nothing } }
\ No newline at end of file diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/TracePackageContentProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/TracePackageContentProvider.java index 278b29b854..8df266d09a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/TracePackageContentProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/TracePackageContentProvider.java @@ -24,10 +24,12 @@ public class TracePackageContentProvider implements ITreeContentProvider { @Override public void dispose() { + // Do nothing } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/TracePackageLabelProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/TracePackageLabelProvider.java index 52687608df..78b383399e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/TracePackageLabelProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/TracePackageLabelProvider.java @@ -28,10 +28,12 @@ public class TracePackageLabelProvider extends ColumnLabelProvider { @Override public void addListener(ILabelProviderListener listener) { + // Do nothing } @Override public void dispose() { + // Do nothing } @Override @@ -41,6 +43,7 @@ public class TracePackageLabelProvider extends ColumnLabelProvider { @Override public void removeListener(ILabelProviderListener listener) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java index e70be8ba50..e6f05b3c18 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java @@ -96,10 +96,12 @@ public class ExportTracePackageSelectTraceWizardPage extends WizardPage { traceViewer.setContentProvider(new IStructuredContentProvider() { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // Do nothing } @Override public void dispose() { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/util/SymbolHelper.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/util/SymbolHelper.java index d64facb6ae..dca44c5d75 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/util/SymbolHelper.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/util/SymbolHelper.java @@ -128,6 +128,7 @@ public final class SymbolHelper { int prevLw = gc.getLineWidth(); Color oldColor = gc.getForeground(); gc.setForeground(color); + gc.setLineWidth(Math.max(2, symbolSize / 4)); gc.drawLine(centerX - symbolSize, centerY, centerX + symbolSize, centerY); gc.drawLine(centerX, centerY - symbolSize, centerX, centerY + symbolSize); gc.setLineStyle(prevLs); @@ -154,6 +155,7 @@ public final class SymbolHelper { int prevLw = gc.getLineWidth(); Color oldColor = gc.getForeground(); gc.setForeground(color); + gc.setLineWidth(Math.max(2, symbolSize / 4)); gc.drawLine(centerX - symbolSize, centerY - symbolSize, centerX + symbolSize, centerY + symbolSize); gc.drawLine(centerX - symbolSize, centerY + symbolSize, centerX + symbolSize, centerY - symbolSize); gc.setLineStyle(prevLs); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/model/TmfPieChartStatisticsModel.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/model/TmfPieChartStatisticsModel.java index 5877a16e3e..18971a3ce0 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/model/TmfPieChartStatisticsModel.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/model/TmfPieChartStatisticsModel.java @@ -38,6 +38,7 @@ public class TmfPieChartStatisticsModel { * Default constructor */ public TmfPieChartStatisticsModel() { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java index fb4e0edf37..0709ecd5d9 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java @@ -45,9 +45,11 @@ public class TmfTreeContentProvider implements ITreeContentProvider { @Override public void dispose() { + // Do nothing } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // Do nothing } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/xycharts/TmfXYChartTimeAdapter.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/xycharts/TmfXYChartTimeAdapter.java index d1a41279eb..de54160348 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/xycharts/TmfXYChartTimeAdapter.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/xycharts/TmfXYChartTimeAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 Ericsson + * Copyright (c) 2017, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -23,6 +23,7 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeForma public final class TmfXYChartTimeAdapter implements ITimeDataProvider { private final TmfXYChartViewer fTimeProvider; + private TimeFormat fTimeFormat; /** * Constructor, requires a {@link ITmfChartTimeProvider} @@ -97,7 +98,7 @@ public final class TmfXYChartTimeAdapter implements ITimeDataProvider { @Override public TimeFormat getTimeFormat() { - return TimeFormat.CALENDAR; + return fTimeFormat; } @Override @@ -148,4 +149,13 @@ public final class TmfXYChartTimeAdapter implements ITimeDataProvider { // Do nothing } + /** + * Set the time format. + * + * @param timeFormat + * the time format + */ + public void setTimeFormat(org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.TimeFormat timeFormat) { + fTimeFormat = TimeFormat.convert(timeFormat); + } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/histogram/HistogramTimeAdapter.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/histogram/HistogramTimeAdapter.java index fdd0445e74..f1468e4f55 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/histogram/HistogramTimeAdapter.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/histogram/HistogramTimeAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Ericsson + * Copyright (c) 2018, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -24,6 +24,7 @@ public class HistogramTimeAdapter implements ITimeDataProvider { private final HistogramDataModel fHistogram; private int fTimeScale = 1; + private TimeFormat fTimeFormat; /** * Constructor. @@ -132,7 +133,7 @@ public class HistogramTimeAdapter implements ITimeDataProvider { @Override public TimeFormat getTimeFormat() { - return TimeFormat.CALENDAR; + return fTimeFormat; } /** @@ -144,4 +145,14 @@ public class HistogramTimeAdapter implements ITimeDataProvider { public void setTimeSpace(int timeSpace) { fTimeScale = timeSpace; } + + /** + * Set the time format + * + * @param timeFormat + * the time format + */ + public void setTimeFormat(org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.TimeFormat timeFormat) { + fTimeFormat = TimeFormat.convert(timeFormat); + } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java index 71ff031e5a..0b5e3243d4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java @@ -97,10 +97,12 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus @Override public void doSave(final IProgressMonitor monitor) { + // Do nothing } @Override public void doSaveAs() { + // Do nothing } @Override @@ -510,14 +512,17 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus @Override public void partClosed(IWorkbenchPart part) { + // Do nothing } @Override public void partDeactivated(IWorkbenchPart part) { + // Do nothing } @Override public void partOpened(IWorkbenchPart part) { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/UnsortedPropertySheetPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/UnsortedPropertySheetPage.java index 74e5335986..d83941b9db 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/UnsortedPropertySheetPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/UnsortedPropertySheetPage.java @@ -32,6 +32,7 @@ public class UnsortedPropertySheetPage extends PropertySheetPage { setSorter(new PropertySheetSorter() { @Override public void sort(IPropertySheetEntry[] entries) { + // Empty sorter, do nothing } }); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfAnalysisElement.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfAnalysisElement.java index 53c5153122..d7940acbd1 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfAnalysisElement.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfAnalysisElement.java @@ -413,6 +413,7 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt */ @Override public final void resetPropertyValue(Object id) { + // Do nothing } /** @@ -420,6 +421,7 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt */ @Override public final void setPropertyValue(Object id, Object value) { + // Do nothing } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentElement.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentElement.java index adaea92848..c8adbdc35d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentElement.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentElement.java @@ -612,10 +612,12 @@ public class TmfExperimentElement extends TmfCommonProjectElement implements IPr @Override public void resetPropertyValue(Object id) { + // Do nothing } @Override public void setPropertyValue(Object id, Object value) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentFolder.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentFolder.java index 090ef03741..780f4f6ed9 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentFolder.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentFolder.java @@ -255,10 +255,12 @@ public class TmfExperimentFolder extends TmfProjectModelElement implements IProp @Override public void resetPropertyValue(Object id) { + // Do nothing } @Override public void setPropertyValue(Object id, Object value) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfNavigatorContentProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfNavigatorContentProvider.java index 4c6f9267bc..f6e0c3867a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfNavigatorContentProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfNavigatorContentProvider.java @@ -111,22 +111,27 @@ public class TmfNavigatorContentProvider implements IPipelinedTreeContentProvide @Override public void dispose() { + // Do nothing } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // Do nothing } @Override public void restoreState(IMemento aMemento) { + // Do nothing } @Override public void saveState(IMemento aMemento) { + // Do nothing } @Override public void init(ICommonContentExtensionSite aConfig) { + // Do nothing } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfNavigatorLabelProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfNavigatorLabelProvider.java index 9f670c7e5b..ed13b8cfa8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfNavigatorLabelProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfNavigatorLabelProvider.java @@ -64,10 +64,12 @@ public class TmfNavigatorLabelProvider implements ICommonLabelProvider, IStyledL @Override public void addListener(ILabelProviderListener listener) { + // Do nothing } @Override public void dispose() { + // Do nothing } @Override @@ -77,14 +79,17 @@ public class TmfNavigatorLabelProvider implements ICommonLabelProvider, IStyledL @Override public void removeListener(ILabelProviderListener listener) { + // Do nothing } @Override public void restoreState(IMemento aMemento) { + // Do nothing } @Override public void saveState(IMemento aMemento) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceElement.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceElement.java index 53fee2694e..9a2cfe19d5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceElement.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceElement.java @@ -633,10 +633,12 @@ public class TmfTraceElement extends TmfCommonProjectElement implements IActionF @Override public void resetPropertyValue(Object id) { + // Do nothing } @Override public void setPropertyValue(Object id, Object value) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceFolder.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceFolder.java index 4fa1a49df4..38a5c91095 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceFolder.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceFolder.java @@ -262,10 +262,12 @@ public class TmfTraceFolder extends TmfProjectModelElement implements IActionFil @Override public void resetPropertyValue(Object id) { + // Do nothing } @Override public void setPropertyValue(Object id, Object value) { + // Do nothing } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceTypeUIUtils.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceTypeUIUtils.java index d093d8bbe5..4cc0c61311 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceTypeUIUtils.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceTypeUIUtils.java @@ -116,7 +116,7 @@ public final class TmfTraceTypeUIUtils { @Override public void widgetDefaultSelected(SelectionEvent e) { - + // Do nothing } }); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/signal/TmfUiSignalThrottler.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/signal/TmfUiSignalThrottler.java new file mode 100644 index 0000000000..24dee46420 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/signal/TmfUiSignalThrottler.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2019 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tasse - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.tracecompass.tmf.ui.signal; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.swt.widgets.Display; +import org.eclipse.tracecompass.tmf.core.component.ITmfComponent; +import org.eclipse.tracecompass.tmf.core.signal.TmfSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; +import org.eclipse.tracecompass.tmf.core.signal.TmfSignalThrottler; + +/** + * "Buffer" between a TmfComponent and the signal manager. You can use this if + * you want to throttle the amount of signals your component will send. + * <p> + * It works by specifying a delay, then calling {@link #queue}. The signals will + * only be really sent if no other call to {@link #queue} happens within $delay + * milliseconds afterwards. This guarantees that only the *last* signal is + * actually broadcasted. + * <p> + * Note that this class does not discriminate for signal types, sources, or + * whatever. If you want to throttle different signals in different ways, you + * can use multiple signal throttlers in your component and call them + * accordingly. + * <p> + * Unlike {@link TmfSignalThrottler}, this throttler will broadcast + * the signal from the UI thread. + * + * @since 5.0 + */ +public class TmfUiSignalThrottler extends TmfSignalThrottler { + + /** + * Constructor + * + * @param component + * The optional source component of the signals. If non-null, its + * {@link ITmfComponent#broadcast} method will be used to finally + * send the signal. If null, the generic + * {@link TmfSignalManager#dispatchSignal} is used. + * @param delay + * Time to wait before actually sending signals (in ms) + */ + public TmfUiSignalThrottler(@Nullable ITmfComponent component, long delay) { + super(component, delay); + } + + @Override + protected void dispatchSignal(@NonNull TmfSignal signal) { + Display.getDefault().asyncExec(() -> super.dispatchSignal(signal)); + } +} diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfAbstractToolTipHandler.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfAbstractToolTipHandler.java index 92c0fbcf40..1a7684767d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfAbstractToolTipHandler.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfAbstractToolTipHandler.java @@ -9,11 +9,30 @@ package org.eclipse.tracecompass.tmf.ui.viewers; +import java.text.Format; +import java.text.NumberFormat; +import java.util.Locale; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.StringEscapeUtils; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTError; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.browser.LocationEvent; +import org.eclipse.swt.browser.LocationListener; +import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseTrackAdapter; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -23,8 +42,19 @@ 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.Slider; +import org.eclipse.tracecompass.common.core.format.DecimalUnitFormat; +import org.eclipse.tracecompass.internal.tmf.ui.Activator; +import org.eclipse.tracecompass.internal.tmf.ui.ITmfUIPreferences; +import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphTooltipHandler; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; +import com.google.common.primitives.Longs; + /** * Abstract tool tip handler. * @@ -32,11 +62,174 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphToolti * @author Loic Prieur-Drevon - extracted from {@link TimeGraphTooltipHandler} */ public abstract class TmfAbstractToolTipHandler { + + private static Format sNumberFormat = NumberFormat.getNumberInstance(Locale.getDefault()); + + /** + * String used for tool tip category, name or value + * + * @since 5.0 + */ + public static class ToolTipString { + + private final String fText; + private final String fHtmlString; + + private ToolTipString(String text, String htmlString) { + fText = text; + fHtmlString = htmlString; + } + + /** + * Returns the HTML string representation of this tool tip string. + * + * @return the HTML string + */ + public String toHtmlString() { + return fHtmlString; + } + + /** + * Returns the plain text representation of this tool tip string. + * + * @return the plain text string + */ + @Override + public String toString() { + return fText; + } + + /** + * Creates a tool tip string from a plain text string + * + * @param text the plain text string + * @return the tool tip string + */ + public static ToolTipString fromString(String text) { + return new ToolTipString(text, toHtmlString(text)); + } + + /** + * Creates a tool tip string from an HTML string + * + * @param htmlString the HTML string + * @return the tool tip string + */ + public static ToolTipString fromHtml(String htmlString) { + return new ToolTipString(toText(htmlString), htmlString); + } + + /** + * Creates a tool tip string from a decimal number. The HTML string mirror the string value. + * + * @param decimal + * The number to format + * @return the tool tip string + */ + public static ToolTipString fromDecimal(Number decimal) { + Format format = sNumberFormat; + if (format == null) { + format = NumberFormat.getInstance(Locale.getDefault()); + if (format == null) { + format = new DecimalUnitFormat(); + } + sNumberFormat = format; + } + String number = format.format(decimal); + return new ToolTipString(number, toHtmlString(number)); + } + + /** + * Creates a tool tip string from a timestamp. The HTML string will + * contain an hyperlink to the timestamp. + * + * @param text + * the timestamp plain text representation + * @param timestamp + * the timestamp in nanoseconds + * @return the tool tip string + */ + public static ToolTipString fromTimestamp(String text, long timestamp) { + return new ToolTipString(text, String.format(TIME_HYPERLINK, timestamp, toHtmlString(text))); + } + + private static String toHtmlString(String text) { + return StringEscapeUtils.escapeHtml4(text) + .replaceAll("[ \\t]", " ") //$NON-NLS-1$ //$NON-NLS-2$ + .replaceAll("\\r?\\n", "<br>"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + private static String toText(String htmlString) { + return StringEscapeUtils.unescapeHtml4(htmlString.replaceAll("\\<[^>]*>", "")); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj == null) { + return false; + } + if (obj.getClass() != getClass()) { + return false; + } + ToolTipString other = (ToolTipString) obj; + return Objects.equals(fText, other.fText) && Objects.equals(fHtmlString, other.fHtmlString); + } + + @Override + public int hashCode() { + return Objects.hash(fText, fHtmlString); + } + } + + private static final int MAX_SHELL_WIDTH = 750; + private static final int MAX_SHELL_HEIGHT = 700; private static final int MOUSE_DEADZONE = 5; + private static final String TIME_HYPERLINK = "<a href=time://%d>%s</a>"; //$NON-NLS-1$ + private static final Pattern TIME_PATTERN = Pattern.compile("\\s*time\\:\\/\\/(\\d+).*"); //$NON-NLS-1$ + + private static final ToolTipString UNCATEGORIZED = ToolTipString.fromString(""); //$NON-NLS-1$ private static final int OFFSET = 16; + private static Point fScrollBarSize = null; private Composite fTipComposite; private Shell fTipShell; private Rectangle fInitialDeadzone; + private MouseTrackAdapter fMouseTrackAdapter; + /** Table of tooltip string information as (category, name, value) tuples */ + private Table<ToolTipString, ToolTipString, ToolTipString> fModel = HashBasedTable.create(); + + private static synchronized boolean isBrowserAvailable(Composite parent) { + boolean isBrowserAvailable = Activator.getDefault().getPreferenceStore().getBoolean(ITmfUIPreferences.USE_BROWSER_TOOLTIPS); + if (isBrowserAvailable) { + try { + getScrollbarSize(parent); + + Browser browser = new Browser(parent, SWT.NONE); + browser.dispose(); + isBrowserAvailable = true; + } catch (SWTError er) { + isBrowserAvailable = false; + } + } + return isBrowserAvailable; + } + + private static synchronized Point getScrollbarSize(Composite parent) { + if (fScrollBarSize == null) { + // Don't move these lines below the new Browser() line + Slider sliderV = new Slider(parent, SWT.VERTICAL); + Slider sliderH = new Slider(parent, SWT.HORIZONTAL); + int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; + int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; + Point scrollBarSize = new Point(width, height); + sliderV.dispose(); + sliderH.dispose(); + fScrollBarSize = scrollBarSize; + } + return fScrollBarSize; + } /** * Important note: this is being added to a display filter, this may leak, @@ -85,48 +278,75 @@ public abstract class TmfAbstractToolTipHandler { * The control object to use */ public void activateHoverHelp(final Control control) { - - control.addMouseTrackListener(new MouseTrackAdapter() { - @Override - public void mouseHover(MouseEvent event) { - // Is application not in focus? - // -OR- a mouse button is pressed - if (Display.getDefault().getFocusControl() == null - || (event.stateMask & SWT.BUTTON_MASK) != 0 - || (event.stateMask & SWT.KEY_MASK) != 0) { - return; - } - Point pt = new Point(event.x, event.y); - Control timeGraphControl = (Control) event.widget; - Point ptInDisplay = control.toDisplay(event.x, event.y); - fInitialDeadzone = new Rectangle(ptInDisplay.x - MOUSE_DEADZONE, ptInDisplay.y - MOUSE_DEADZONE, 2 * MOUSE_DEADZONE, 2 * MOUSE_DEADZONE); - createTooltipShell(timeGraphControl.getShell()); - for (Control child : fTipComposite.getChildren()) { - child.dispose(); + MouseTrackAdapter adapter = fMouseTrackAdapter; + if (adapter == null) { + adapter = new MouseTrackAdapter() { + @Override + public void mouseHover(MouseEvent event) { + // Is application not in focus? + // -OR- a mouse button is pressed + if (Display.getDefault().getFocusControl() == null + || (event.stateMask & SWT.BUTTON_MASK) != 0 + || (event.stateMask & SWT.KEY_MASK) != 0) { + return; + } + Point pt = new Point(event.x, event.y); + Control timeGraphControl = (Control) event.widget; + Point ptInDisplay = control.toDisplay(event.x, event.y); + fInitialDeadzone = new Rectangle(ptInDisplay.x - MOUSE_DEADZONE, ptInDisplay.y - MOUSE_DEADZONE, 2 * MOUSE_DEADZONE, 2 * MOUSE_DEADZONE); + createTooltipShell(timeGraphControl.getShell(), control, event, pt); + if (fTipComposite.getChildren().length == 0) { + // avoid displaying empty tool tips. + return; + } + Point tipPosition = control.toDisplay(pt); + setHoverLocation(fTipShell, tipPosition); + fTipShell.setVisible(true); + // Register Display filters. + Display display = Display.getDefault(); + display.addFilter(SWT.MouseMove, fListener); + display.addFilter(SWT.FocusOut, fFocusLostListener); } - fill(control, event, pt); - if (fTipComposite.getChildren().length == 0) { - // avoid displaying empty tool tips. - return; - } - fTipShell.pack(); - Point tipPosition = control.toDisplay(pt); - setHoverLocation(fTipShell, tipPosition); - fTipShell.setVisible(true); - // Register Display filters. - Display display = Display.getDefault(); - display.addFilter(SWT.MouseMove, fListener); - display.addFilter(SWT.FocusOut, fFocusLostListener); - } - }); + }; + control.addMouseTrackListener(adapter); + fMouseTrackAdapter = adapter; + } + } + + /** + * Callback for the mouse-over tooltip to deactivate hoverhelp + * + * @param control + * The control object to use + * @since 5.0 + */ + public void deactivateHoverHelp(final Control control) { + MouseTrackAdapter adapter = fMouseTrackAdapter; + if (adapter != null) { + control.removeMouseTrackListener(adapter); + fMouseTrackAdapter = null; + } } - private void createTooltipShell(Shell parent) { + /** + * Create the tooltip shell. + * + * @param parent + * the parent shell + * @param control + * the underlying control + * @param event + * the mouse event to react to + * @param pt + * the mouse hover position in the control's coordinates + */ + private void createTooltipShell(Shell parent, Control control, MouseEvent event, Point pt) { final Display display = parent.getDisplay(); if (fTipShell != null && !fTipShell.isDisposed()) { fTipShell.dispose(); } - fTipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL); + fModel.clear(); + fTipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL | SWT.RESIZE | SWT.NO_SCROLL); // Deregister display filters on dispose fTipShell.addDisposeListener(e -> e.display.removeFilter(SWT.MouseMove, fListener)); fTipShell.addDisposeListener(e -> e.display.removeFilter(SWT.FocusOut, fFocusLostListener)); @@ -135,15 +355,25 @@ public abstract class TmfAbstractToolTipHandler { fTipShell.dispose(); } }); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - gridLayout.marginWidth = 2; - gridLayout.marginHeight = 2; - fTipShell.setLayout(gridLayout); + fTipShell.setLayout(new FillLayout()); fTipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - fTipComposite = new Composite(fTipShell, SWT.NONE); - fTipComposite.setLayout(new GridLayout(3, false)); - setupControl(fTipComposite); + + fTipComposite = new Composite(fTipShell, SWT.NO_FOCUS); + fTipComposite.setLayout(new FillLayout()); + fill(control, event, pt); + + ITooltipContent content = null; + if (isBrowserAvailable(fTipComposite)) { + content = new BrowserContent(fTipComposite); + } else { + content = new DefaultContent(fTipComposite); + } + content.setInput(fModel); + content.create(); + Point p = content.computePreferredSize(); + Point scrollBarSize = getScrollbarSize(fTipComposite); + Rectangle t = fTipShell.computeTrim(0, 0, p.x + scrollBarSize.x, p.y); + fTipShell.setSize(Math.min(t.width, MAX_SHELL_WIDTH), Math.min(t.height, MAX_SHELL_HEIGHT)); } private static void setHoverLocation(Shell shell, Point position) { @@ -162,11 +392,6 @@ public abstract class TmfAbstractToolTipHandler { shell.setBounds(shellBounds); } - private void setupControl(Control control) { - control.setForeground(fTipShell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - control.setBackground(fTipShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - } - /** * Getter for the current underlying tip {@link Composite} * @@ -177,7 +402,8 @@ public abstract class TmfAbstractToolTipHandler { } /** - * Method to call to add tuples : name, value to the tooltip. + * Adds an uncategorized (name, value) tuple to the tool tip. The name and + * value are plain text strings. * * @param name * name of the line @@ -185,23 +411,43 @@ public abstract class TmfAbstractToolTipHandler { * line value */ protected void addItem(String name, String value) { - Label nameLabel = new Label(fTipComposite, SWT.NO_FOCUS); - nameLabel.setText(name); - setupControl(nameLabel); - Label separator = new Label(fTipComposite, SWT.NO_FOCUS | SWT.SEPARATOR | SWT.VERTICAL); - GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false); - gd.heightHint = nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; - separator.setLayoutData(gd); - setupControl(separator); - Label valueLabel = new Label(fTipComposite, SWT.NO_FOCUS); - valueLabel.setText(value); - setupControl(valueLabel); + addItem(null, ToolTipString.fromString(name), ToolTipString.fromString(value)); + } + + /** + * Adds a (category, name, value) tuple to the tool tip. The category, name and + * value are plain text strings. + * + * @param category + * the category of the item (used for grouping) + * @param name + * name of the line + * @param value + * line value + * @since 5.0 + */ + protected void addItem(String category, String name, String value) { + addItem(category == null ? null : ToolTipString.fromString(category), ToolTipString.fromString(name), ToolTipString.fromString(value)); + } + + /** + * Adds a (category, name, value) tuple to the tool tip. + * + * @param category + * the category of the item (used for grouping) + * @param name + * name of the line + * @param value + * line value + * @since 5.0 + */ + protected void addItem(ToolTipString category, ToolTipString name, ToolTipString value) { + fModel.put(category == null ? UNCATEGORIZED : category, name, value); } /** - * Abstract method to override within implementations. Call - * {@link TmfAbstractToolTipHandler#addItem(String, String)} to populate the - * tool tip. + * Abstract method to override within implementations. Call the addItem() + * methods to populate the tool tip. * * @param control * the underlying control @@ -212,4 +458,273 @@ public abstract class TmfAbstractToolTipHandler { */ protected abstract void fill(Control control, MouseEvent event, Point pt); + private interface ITooltipContent { + void create(); + void setInput(Table<ToolTipString, ToolTipString, ToolTipString> model); + Point computePreferredSize(); + + default void setupControl(Control control) { + control.setForeground(control.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND)); + control.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); + } + } + + private class BrowserContent extends AbstractContent { + private static final int MARGIN = 10; + + public BrowserContent(Composite parent) { + super(parent); + } + + @Override + public void create() { + Composite parent = getParent(); + Table<ToolTipString, ToolTipString, ToolTipString> model = getModel(); + if (parent == null || model.size() == 0) { + return; + } + setupControl(parent); + ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); + scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + scrolledComposite.setExpandVertical(true); + scrolledComposite.setExpandHorizontal(true); + + Browser browser = new Browser(scrolledComposite, SWT.NONE); + browser.setJavascriptEnabled(false); + browser.addLocationListener(new LocationListener() { + @Override + public void changing(LocationEvent ev) { + Matcher matcher = TIME_PATTERN.matcher(ev.location); + if (matcher.find()) { + String time = matcher.group(1); + Long val = Longs.tryParse(time); + if (val != null) { + TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(ev.getSource(), TmfTimestamp.fromNanos(val))); + } + ev.doit = false; + } + } + @Override + public void changed(LocationEvent ev) { + // Ignore + } + }); + setupControl(browser); + + String toolTipHtml = toHtml(); + browser.setText(toolTipHtml); + scrolledComposite.setContent(browser); + Point preferredSize = computePreferredSize(); + Point scrollBarSize = getScrollbarSize(scrolledComposite); + scrolledComposite.setMinSize(Math.min(preferredSize.x + scrollBarSize.x, MAX_SHELL_WIDTH - scrollBarSize.x), 0); + } + + @Override + public Point computePreferredSize() { + Table<ToolTipString, ToolTipString, ToolTipString> model = getModel(); + int widestCat = 0; + int widestKey = 0; + int widestVal = 0; + int totalHeight = 0; + Set<ToolTipString> rowKeySet = model.rowKeySet(); + GC gc = new GC(Display.getDefault()); + for (ToolTipString row : rowKeySet) { + if (!row.equals(UNCATEGORIZED)) { + Point catExtent = gc.textExtent(row.toString()); + widestCat = Math.max(widestCat, catExtent.x); + totalHeight += catExtent.y + 8; + } + Set<@NonNull Entry<ToolTipString, ToolTipString>> entrySet = model.row(row).entrySet(); + for (Entry<ToolTipString, ToolTipString> entry : entrySet) { + Point keyExtent = gc.textExtent(entry.getKey().toString()); + Point valExtent = gc.textExtent(entry.getValue().toString()); + widestKey = Math.max(widestKey, keyExtent.x); + widestVal = Math.max(widestVal, valExtent.x); + totalHeight += Math.max(keyExtent.y, valExtent.y) + 4; + } + } + gc.dispose(); + int w = Math.max(widestCat, widestKey + MARGIN + widestVal) + 2 * MARGIN; + int h = totalHeight + 2 * MARGIN; + return new Point(w, h); + } + + @SuppressWarnings("nls") + private String toHtml() { + GC gc = new GC(Display.getDefault()); + FontData fontData = gc.getFont().getFontData()[0]; + String fontName = fontData.getName(); + String fontHeight = fontData.getHeight() + "pt"; + gc.dispose(); + Table<ToolTipString, ToolTipString, ToolTipString> model = getModel(); + StringBuilder toolTipContent = new StringBuilder(); + toolTipContent.append("<head>\n" + + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n" + + "<style>\n" + + ".collapsible {\n" + + " background-color: #777;\n" + + " color: white;\n" + +// " cursor: pointer;\n" + // Add when enabling JavaScript + " padding: 0px;\n" + + " width: 100%;\n" + + " border: none;\n" + + " text-align: left;\n" + + " outline: none;\n" + + " font-family: " + fontName +";\n" + + " font-size: " + fontHeight + ";\n" + + "}\n" + + "\n" + + ".active, .collapsible:hover {\n" + + " background-color: #555;\n" + + "}\n" + + "\n" + + ".content {\n" + + " padding: 0px 0px;\n" + + " display: block;\n" + + " overflow: hidden;\n" + + " background-color: #f1f1f1;\n" + + "}\n" + + ".tab {\n" + + " padding:0px;\n" + + " font-family: " + fontName +";\n" + + " font-size: " + fontHeight + ";\n" + + "}\n" + + ".leftPadding {\n" + + " padding:0px 0px 0px 10px;\n" + + "}\n" + + ".bodystyle {\n" + + " padding:0px 0px;\n" + + "}\n" + + "</style>\n" + + "</head>"); + toolTipContent.append("<body class=\"bodystyle\">"); //$NON-NLS-1$ + + toolTipContent.append("<div class=\"content\">"); + toolTipContent.append("<table class=\"tab\">"); + Set<ToolTipString> rowKeySet = model.rowKeySet(); + for (ToolTipString row : rowKeySet) { + if (!row.equals(UNCATEGORIZED)) { + toolTipContent.append("<tr><th colspan=\"2\"><button class=\"collapsible\">").append(row.toHtmlString()).append("</button></th></tr>"); + } + Set<@NonNull Entry<ToolTipString, ToolTipString>> entrySet = model.row(row).entrySet(); + for (Entry<ToolTipString, ToolTipString> entry : entrySet) { + toolTipContent.append("<tr>"); + toolTipContent.append("<td>"); + toolTipContent.append(entry.getKey().toHtmlString()); + toolTipContent.append("</td>"); + toolTipContent.append("<td class=\"leftPadding\">"); + toolTipContent.append(entry.getValue().toHtmlString()); + toolTipContent.append("</td>"); + toolTipContent.append("</tr>"); + } + } + toolTipContent.append("</table></div>"); + /* Add when enabling JavaScript + toolTipContent.append("\n" + + "<script>\n" + + "var coll = document.getElementsByClassName(\"collapsible\");\n" + + "var i;\n" + + "\n" + + "for (i = 0; i < coll.length; i++) {\n" + + " coll[i].addEventListener(\"click\", function() {\n" + + " this.classList.toggle(\"active\");\n" + + " var content = this.nextElementSibling;\n" + + " if (content.style.display === \"block\") {\n" + + " content.style.display = \"none\";\n" + + " } else {\n" + + " content.style.display = \"block\";\n" + + " }\n" + + " });\n" + + "}\n" + + "</script>"); + */ + toolTipContent.append("</body>"); //$NON-NLS-1$ + return toolTipContent.toString(); + } + } + + private class DefaultContent extends AbstractContent { + public DefaultContent(Composite parent) { + super(parent); + } + + @Override + public void create() { + Composite parent = getParent(); + Table<ToolTipString, ToolTipString, ToolTipString> model = getModel(); + if (parent == null || model.size() == 0) { + return; + } + setupControl(parent); + parent.setLayout(new GridLayout()); + + ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); + scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + scrolledComposite.setExpandVertical(true); + scrolledComposite.setExpandHorizontal(true); + setupControl(scrolledComposite); + + Composite composite = new Composite(scrolledComposite, SWT.NONE); + composite.setLayout(new GridLayout(3, false)); + setupControl(composite); + Set<ToolTipString> rowKeySet = model.rowKeySet(); + for (ToolTipString row : rowKeySet) { + Set<@NonNull Entry<ToolTipString, ToolTipString>> entrySet = model.row(row).entrySet(); + for (Entry<ToolTipString, ToolTipString> entry : entrySet) { + Label nameLabel = new Label(composite, SWT.NO_FOCUS); + nameLabel.setText(entry.getKey().toString()); + setupControl(nameLabel); + Label separator = new Label(composite, SWT.NO_FOCUS | SWT.SEPARATOR | SWT.VERTICAL); + GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false); + gd.heightHint = nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; + separator.setLayoutData(gd); + setupControl(separator); + Label valueLabel = new Label(composite, SWT.NO_FOCUS); + valueLabel.setText(entry.getValue().toString()); + setupControl(valueLabel); + } + } + scrolledComposite.setContent(composite); + Point preferredSize = computePreferredSize(); + Point scrollBarSize = getScrollbarSize(composite); + scrolledComposite.setMinSize(preferredSize.x > scrollBarSize.x ? preferredSize.x - scrollBarSize.x : preferredSize.x, preferredSize.y > scrollBarSize.y ? preferredSize.y - scrollBarSize.y : preferredSize.y); + } + } + + private abstract class AbstractContent implements ITooltipContent { + private Composite fParent = null; + private Table<ToolTipString, ToolTipString, ToolTipString> fContentModel = null; + + public AbstractContent(Composite parent) { + fParent = parent; + } + + @Override + public void setInput(Table<ToolTipString, ToolTipString, ToolTipString> model) { + fContentModel = model; + } + + @NonNull + protected Table<ToolTipString, ToolTipString, ToolTipString> getModel() { + Table<ToolTipString, ToolTipString, ToolTipString> model = fContentModel; + if (model == null) { + model = HashBasedTable.create(); + } + return model; + } + + @Override + public Point computePreferredSize() { + Composite parent = fParent; + if (parent == null) { + return new Point(0, 0); + } + return parent.computeSize(SWT.DEFAULT, SWT.DEFAULT); + } + + protected Composite getParent() { + return fParent; + } + } + } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfTimeViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfTimeViewer.java index 4971edce58..3f7df6b857 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfTimeViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfTimeViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 École Polytechnique de Montréal and others. + * Copyright (c) 2014, 2019 École Polytechnique de Montréal and others. * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -18,7 +18,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; -import org.eclipse.tracecompass.tmf.core.signal.TmfSignalThrottler; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal; @@ -31,6 +30,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.ui.signal.TmfUiSignalThrottler; import org.eclipse.tracecompass.tmf.ui.views.ITmfPinnable; /** @@ -67,7 +67,7 @@ public abstract class TmfTimeViewer extends TmfViewer implements ITmfTimeProvide /** The trace that is displayed by this viewer */ private ITmfTrace fTrace; /** A signal throttler for range updates */ - private final TmfSignalThrottler fTimeRangeSyncThrottle = new TmfSignalThrottler(this, 200); + private final TmfUiSignalThrottler fTimeRangeSyncThrottle = new TmfUiSignalThrottler(this, 200); /** * Default constructor. diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java index 24d1d22d39..27b7179dfa 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java @@ -886,11 +886,22 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS // Setup the columns for (ITmfEventAspect<?> aspect : aspects) { if (aspect != null) { - fColumns.add(new TmfEventTableColumn(aspect)); - + String aspectName = aspect.getName(); + Boolean unique = true; + for (TmfEventTableColumn column : fColumns) { + if (column.getHeaderName().equals(aspectName)) { + unique = false; + column.addDuplicate(aspect); + break; + } + } + if (unique) { + fColumns.add(new TmfEventTableColumn(aspect)); + } } } + TmfMarginColumn collapseCol = new TmfMarginColumn(); fColumns.add(MARGIN_COLUMN_INDEX, collapseCol); @@ -2686,7 +2697,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS */ private void createResources() { ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); - Color c = colorRegistry.get("org.eclipse.tracecompass.tmf.ui.FOREGROUND"); + Color c = colorRegistry.get("org.eclipse.tracecompass.tmf.ui.FOREGROUND"); //$NON-NLS-1$ if (c != null) { fGrayColor = c; } else { diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/columns/TmfEventTableColumn.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/columns/TmfEventTableColumn.java index bb1062876b..7624a7878c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/columns/TmfEventTableColumn.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/columns/TmfEventTableColumn.java @@ -12,6 +12,9 @@ package org.eclipse.tracecompass.tmf.ui.viewers.events.columns; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.common.core.NonNullUtils; @@ -38,7 +41,8 @@ public class TmfEventTableColumn { // Fields // ------------------------------------------------------------------------ - private final ITmfEventAspect<?> fAspect; + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ + private final List<ITmfEventAspect<?>> fAspects = new ArrayList<>(); // ------------------------------------------------------------------------ // Constructors @@ -52,7 +56,21 @@ public class TmfEventTableColumn { * column. */ public TmfEventTableColumn(ITmfEventAspect<?> aspect) { - fAspect = aspect; + fAspects.add(aspect); + } + + // ------------------------------------------------------------------------ + // adders + // ------------------------------------------------------------------------ + /** + * Add another Aspect with the same name + * + * @param duplicate + * the aspect with the same name + * @since 5.0 + */ + public void addDuplicate(ITmfEventAspect<?> duplicate) { + fAspects.add(duplicate); } // ------------------------------------------------------------------------ @@ -65,7 +83,7 @@ public class TmfEventTableColumn { * @return The column's title */ public String getHeaderName() { - return fAspect.getName(); + return fAspects.get(0).getName(); } /** @@ -74,7 +92,7 @@ public class TmfEventTableColumn { * @return The header's tooltip */ public @Nullable String getHeaderTooltip() { - return fAspect.getHelpText(); + return fAspects.get(0).getHelpText(); } /** @@ -87,7 +105,13 @@ public class TmfEventTableColumn { * @return The string to display in the column for this event */ public String getItemString(ITmfEvent event) { - return NonNullUtils.nullToEmptyString(fAspect.resolve(event)); + for (ITmfEventAspect<?> aspect : fAspects) { + String eventString = NonNullUtils.nullToEmptyString(aspect.resolve(event)); + if (!eventString.isEmpty()) { + return eventString; + } + } + return EMPTY_STRING; } /** @@ -96,7 +120,7 @@ public class TmfEventTableColumn { * @return The event aspect */ public ITmfEventAspect<?> getEventAspect() { - return fAspect; + return fAspects.get(0); } // ------------------------------------------------------------------------ @@ -107,7 +131,7 @@ public class TmfEventTableColumn { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + fAspect.hashCode(); + result = prime * result + fAspects.get(0).hashCode(); return result; } @@ -124,6 +148,6 @@ public class TmfEventTableColumn { } TmfEventTableColumn other = (TmfEventTableColumn) obj; /* Aspects can also define how they can be "equal" to one another */ - return (fAspect.equals(other.fAspect)); + return (fAspects.get(0).equals(other.fAspects.get(0))); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/TmfTreeViewerToolTipHandler.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/TmfTreeViewerToolTipHandler.java index 2ce164f566..17368bc03e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/TmfTreeViewerToolTipHandler.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/TmfTreeViewerToolTipHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Ericsson + * Copyright (c) 2017, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -41,7 +41,7 @@ public abstract class TmfTreeViewerToolTipHandler extends TmfAbstractToolTipHand /** * Abstract method for implementations to populate the tool tip by calling - * {@link TmfAbstractToolTipHandler#addItem(String, String)}. + * the addItem() methods. * * @param entry * the {@link TmfTreeViewerEntry} which we are hovering above. diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfSimpleTooltipProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfSimpleTooltipProvider.java index ad22dfb491..6a243b7ae2 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfSimpleTooltipProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfSimpleTooltipProvider.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2013, 2014 Ericsson + * Copyright (c) 2013, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -13,17 +13,45 @@ package org.eclipse.tracecompass.tmf.ui.viewers.xycharts; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseTrackListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Control; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; +import org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler; +import org.swtchart.Chart; import org.swtchart.IAxis; +import org.swtchart.IAxisSet; /** - * Tool tip provider for TMF chart viewer. It displays the x and y - * value of the current mouse position. + * Tool tip provider for TMF chart viewer. It displays the x and y value of the + * current mouse position. * * @author Bernd Hufmann */ public class TmfSimpleTooltipProvider extends TmfBaseProvider implements MouseTrackListener { + private final class XYToolTipHandler extends TmfAbstractToolTipHandler { + @Override + public void fill(Control control, MouseEvent event, Point pt) { + Chart chart = getChart(); + IAxisSet axisSet = chart.getAxisSet(); + IAxis xAxis = axisSet.getXAxis(0); + IAxis yAxis = axisSet.getYAxis(0); + + double xCoordinate = xAxis.getDataCoordinate(pt.x); + double yCoordinate = yAxis.getDataCoordinate(pt.y); + + ITmfChartTimeProvider viewer = getChartViewer(); + + ITmfTimestamp time = TmfTimestamp.fromNanos((long) xCoordinate + viewer.getTimeOffset()); + /* set tooltip of current data point */ + addItem(null, ToolTipString.fromString("x"), ToolTipString.fromTimestamp(time.toString(), time.toNanos())); //$NON-NLS-1$ + addItem(null, "y", Double.toString(yCoordinate)); //$NON-NLS-1$ + } + } + + private TmfAbstractToolTipHandler fTooltipHandler = new XYToolTipHandler(); + // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ @@ -31,7 +59,7 @@ public class TmfSimpleTooltipProvider extends TmfBaseProvider implements MouseTr * Constructor for a tool tip provider. * * @param tmfChartViewer - * The parent chart viewer + * The parent chart viewer */ public TmfSimpleTooltipProvider(ITmfChartTimeProvider tmfChartViewer) { super(tmfChartViewer); @@ -43,13 +71,13 @@ public class TmfSimpleTooltipProvider extends TmfBaseProvider implements MouseTr // ------------------------------------------------------------------------ @Override public void register() { - getChart().getPlotArea().addMouseTrackListener(this); + fTooltipHandler.activateHoverHelp(getChart().getPlotArea()); } @Override public void deregister() { if ((getChartViewer().getControl() != null) && !getChartViewer().getControl().isDisposed()) { - getChart().getPlotArea().removeMouseTrackListener(this); + fTooltipHandler.deactivateHoverHelp(getChart().getPlotArea()); } } @@ -71,25 +99,6 @@ public class TmfSimpleTooltipProvider extends TmfBaseProvider implements MouseTr @Override public void mouseHover(MouseEvent e) { - if (getChartViewer().getWindowDuration() == 0) { - return; - } - - IAxis xAxis = getChart().getAxisSet().getXAxis(0); - IAxis yAxis = getChart().getAxisSet().getYAxis(0); - - double xCoordinate = xAxis.getDataCoordinate(e.x); - double yCoordinate = yAxis.getDataCoordinate(e.y); - - ITmfChartTimeProvider viewer = getChartViewer(); - - /* set tooltip of current data point */ - StringBuffer buffer = new StringBuffer(); - buffer.append("x="); //$NON-NLS-1$ - buffer.append(TmfTimestamp.fromNanos((long) xCoordinate + viewer.getTimeOffset()).toString()); - buffer.append("\n"); //$NON-NLS-1$ - buffer.append("y="); //$NON-NLS-1$ - buffer.append((long) yCoordinate); - getChart().getPlotArea().setToolTipText(buffer.toString()); + // do nothing } }
\ No newline at end of file diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfXYChartViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfXYChartViewer.java index 3d9b2468f9..b1281f505f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfXYChartViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfXYChartViewer.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.ui.viewers.xycharts; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; @@ -40,6 +41,8 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimePreferences; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; @@ -48,7 +51,6 @@ import org.eclipse.tracecompass.tmf.ui.viewers.TmfTimeViewer; import org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils; import org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.Resolution; import org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.TimeFormat; -import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphScale; import org.swtchart.Chart; @@ -83,6 +85,8 @@ public abstract class TmfXYChartViewer extends TmfTimeViewer implements ITmfChar private Chart fSwtChart; /** The X axis for the chart */ private TimeGraphScale fTimeScaleCtrl; + /** The time format */ + private @Nullable TimeFormat fTimeFormat = null; /** The mouse selection provider */ private TmfBaseProvider fMouseSelectionProvider; /** The mouse drag zoom provider */ @@ -99,7 +103,7 @@ public abstract class TmfXYChartViewer extends TmfTimeViewer implements ITmfChar */ private boolean fSendTimeAlignSignals = false; - private final ITimeDataProvider fDataProvider; + private final TmfXYChartTimeAdapter fDataProvider; private IStatusLineManager fStatusLineManager; // ------------------------------------------------------------------------ @@ -210,6 +214,7 @@ public abstract class TmfXYChartViewer extends TmfTimeViewer implements ITmfChar fDataProvider = new TmfXYChartTimeAdapter(this); fTimeScaleCtrl.setTimeProvider(fDataProvider); + updateTimeFormat(); } private void initTitle(String label, ITitle titleCtrl) { @@ -451,6 +456,23 @@ public abstract class TmfXYChartViewer extends TmfTimeViewer implements ITmfChar gc.setAlpha(255); } + /** + * Sets the time format, or null to use the Time Format 'Date and Time + * format' preference (default). + * + * @param timeFormat + * the {@link TimeFormat} used to display timestamps + * @since 5.0 + */ + protected void setTimeFormat(TimeFormat timeFormat) { + fTimeFormat = timeFormat; + if (fSwtChart != null) { + updateTimeFormat(); + fSwtChart.getAxisSet().adjustRange(); + fSwtChart.redraw(); + } + } + // ------------------------------------------------------------------------ // Signal Handler // ------------------------------------------------------------------------ @@ -494,6 +516,7 @@ public abstract class TmfXYChartViewer extends TmfTimeViewer implements ITmfChar */ @TmfSignalHandler public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal) { + updateTimeFormat(); fSwtChart.getAxisSet().adjustRange(); fSwtChart.redraw(); } @@ -732,4 +755,16 @@ public abstract class TmfXYChartViewer extends TmfTimeViewer implements ITmfChar }; } + private void updateTimeFormat() { + if (fTimeFormat == null) { + String datime = TmfTimePreferences.getPreferenceMap().get(ITmfTimePreferencesConstants.DATIME); + if (ITmfTimePreferencesConstants.TIME_ELAPSED_FMT.equals(datime)) { + fDataProvider.setTimeFormat(TimeFormat.RELATIVE); + } else { + fDataProvider.setTimeFormat(TimeFormat.CALENDAR); + } + } else { + fDataProvider.setTimeFormat(fTimeFormat); + } + } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartTooltipProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartTooltipProvider.java index 0643346540..68e81facea 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartTooltipProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartTooltipProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 École Polytechnique de Montréal + * Copyright (c) 2014, 2019 École Polytechnique de Montréal and others * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -12,16 +12,23 @@ package org.eclipse.tracecompass.tmf.ui.viewers.xycharts.linecharts; +import java.text.Format; import java.util.Arrays; -import java.util.Formatter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseTrackListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Control; import org.eclipse.tracecompass.internal.tmf.ui.Messages; +import org.eclipse.tracecompass.tmf.core.presentation.IYAppearance; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; +import org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.ITmfChartTimeProvider; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfBaseProvider; +import org.swtchart.Chart; import org.swtchart.IAxis; +import org.swtchart.IAxisSet; import org.swtchart.ISeries; /** @@ -34,6 +41,78 @@ import org.swtchart.ISeries; */ public class TmfCommonXLineChartTooltipProvider extends TmfBaseProvider implements MouseTrackListener { + private final class XYToolTipHandler extends TmfAbstractToolTipHandler { + private static final String HTML_COLOR_TOOLTIP = "<span style=\"color:%s;\">%s</span>"; //$NON-NLS-1$ + + private boolean isValid(int index, ISeries serie) { + double[] ySeries = serie.getYSeries(); + return serie.isVisible() && ySeries != null && ySeries.length > index; + } + + @Override + public void fill(Control control, MouseEvent event, Point pt) { + if (getChartViewer().getWindowDuration() != 0) { + Chart chart = getChart(); + IAxisSet axisSet = chart.getAxisSet(); + IAxis xAxis = axisSet.getXAxis(0); + + double xCoordinate = xAxis.getDataCoordinate(pt.x); + + ISeries[] series = getChart().getSeriesSet().getSeries(); + + if ((xCoordinate < 0) || (series.length == 0)) { + return; + } + + /* Find the index of the value we want */ + double[] xS = series[0].getXSeries(); + if (xS == null) { + return; + } + int index = Arrays.binarySearch(xS, xCoordinate); + index = index >= 0 ? index : -index - 1; + int maxLen = 0; + for (ISeries serie : series) { + /* Make sure the series values and the value at index exist */ + if (isValid(index, serie)) { + maxLen = Math.max(maxLen, serie.getId().length()); + } + } + + TmfCommonXAxisChartViewer viewer = null; + Format format = null; + ITmfChartTimeProvider timeProvider = getChartViewer(); + if (timeProvider instanceof TmfCommonXAxisChartViewer) { + viewer = (TmfCommonXAxisChartViewer) timeProvider; + format = viewer.getSwtChart().getAxisSet().getYAxes()[0].getTick().getFormat(); + } + ITmfTimestamp time = TmfTimestamp.fromNanos((long) xCoordinate + getChartViewer().getTimeOffset()); + addItem(null, ToolTipString.fromString(Messages.TmfCommonXLineChartTooltipProvider_time), ToolTipString.fromTimestamp(time.toString(), time.toNanos())); + /* For each series, get the value at the index */ + for (ISeries serie : series) { + double[] yS = serie.getYSeries(); + /* Make sure the series values and the value at index exist */ + if (isValid(index, serie)) { + String key = serie.getId(); + if (key != null && viewer != null) { + IYAppearance appearance = viewer.getSeriesAppearance(key); + key = String.format(HTML_COLOR_TOOLTIP, appearance.getColor(), key); + + } + double yValue = yS[index]; + if (format == null) { + addItem(null, ToolTipString.fromHtml(key), ToolTipString.fromDecimal(yValue)); + } else { + addItem(null, ToolTipString.fromHtml(key), ToolTipString.fromString(format.format(yValue))); + } + } + } + } + } + } + + private XYToolTipHandler fToolTipHandler = new XYToolTipHandler(); + /** * Constructor for the tooltip provider * @@ -51,13 +130,13 @@ public class TmfCommonXLineChartTooltipProvider extends TmfBaseProvider implemen @Override public void register() { - getChart().getPlotArea().addMouseTrackListener(this); + fToolTipHandler.activateHoverHelp(getChart().getPlotArea()); } @Override public void deregister() { if ((getChartViewer().getControl() != null) && !getChartViewer().getControl().isDisposed()) { - getChart().getPlotArea().removeMouseTrackListener(this); + fToolTipHandler.deactivateHoverHelp(getChart().getPlotArea()); } } @@ -70,67 +149,30 @@ public class TmfCommonXLineChartTooltipProvider extends TmfBaseProvider implemen // MouseTrackListener // ------------------------------------------------------------------------ + /** + * @deprecated, do not extend, use as-is + */ + @Deprecated @Override public void mouseEnter(MouseEvent e) { + // do nothing } + /** + * @deprecated, do not extend, use as-is + */ + @Deprecated @Override public void mouseExit(MouseEvent e) { + // do nothing } + /** + * @deprecated, do not extend, use as-is + */ + @Deprecated @Override public void mouseHover(MouseEvent e) { - if (getChartViewer().getWindowDuration() != 0) { - IAxis xAxis = getChart().getAxisSet().getXAxis(0); - - double xCoordinate = xAxis.getDataCoordinate(e.x); - - ISeries[] series = getChart().getSeriesSet().getSeries(); - - if ((xCoordinate < 0) || (series.length == 0)) { - return; - } - - /* Find the index of the value we want */ - double[] xS = series[0].getXSeries(); - if (xS == null) { - return; - } - int index = Arrays.binarySearch(xS, xCoordinate); - index = index >= 0 ? index : -index - 1; - int maxLen = 0; - for (ISeries serie : series) { - /* Make sure the series values and the value at index exist */ - if (isValid(index, serie)) { - maxLen = Math.max(maxLen, serie.getId().length()); - } - } - - /* set tooltip of closest data point */ - StringBuilder buffer = new StringBuilder(Messages.TmfCommonXLineChartTooltipProvider_time + "\t" //$NON-NLS-1$ - + TmfTimestamp.fromNanos((long) xCoordinate + getChartViewer().getTimeOffset()).toString() + "\n"); //$NON-NLS-1$ - - // FIXME this is overridden by the shell font. - String formatString = "%-" + (maxLen) + "s%12.2f%n"; //$NON-NLS-1$ //$NON-NLS-2$ - try (Formatter formatter = new Formatter(buffer)) { - /* For each series, get the value at the index */ - for (ISeries serie : series) { - double[] yS = serie.getYSeries(); - /* Make sure the series values and the value at index exist */ - if (isValid(index, serie)) { - formatter.format(formatString, serie.getId(), yS[index]); - } - } - } - - getChart().getPlotArea().setToolTipText(buffer.toString()); - getChart().redraw(); - } + // do nothing } - - private static boolean isValid(int index, ISeries serie) { - double[] ySeries = serie.getYSeries(); - return serie.isVisible() && ySeries != null && ySeries.length > index; - } - } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java index 40fe408386..7b4adb0ae6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java @@ -117,8 +117,9 @@ public abstract class TmfChartView extends TmfView implements ITmfTimeAligned, I * Returns the TMF XY chart viewer implementation. * * @return the TMF XY chart viewer {@link TmfXYChartViewer} + * @since 5.0 */ - protected TmfXYChartViewer getChartViewer() { + public TmfXYChartViewer getChartViewer() { return fChartViewer; } @@ -126,9 +127,9 @@ public abstract class TmfChartView extends TmfView implements ITmfTimeAligned, I * Returns the left TMF viewer implementation. * * @return the left TMF viewer {@link TmfViewer} - * @since 3.1 + * @since 5.0 */ - protected TmfViewer getLeftChildViewer() { + public TmfViewer getLeftChildViewer() { return fTmfViewer; } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java index b671257126..728dd74d21 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 Ericsson + * Copyright (c) 2011, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -44,16 +44,20 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.tracecompass.internal.tmf.ui.views.histogram.HistogramTimeAdapter; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimePreferences; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampDelta; import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal; +import org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler; import org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils; import org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.Resolution; import org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.TimeFormat; @@ -235,6 +239,45 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi private TimeGraphScale fTimeLineScale; private TimeGraphColorScheme fColorScheme; + private TmfAbstractToolTipHandler fToolTipHandler = new TmfAbstractToolTipHandler() { + + @Override + protected void fill(Control control, MouseEvent event, Point pt) { + if ((fDataModel.getNbEvents() != 0 || fDataModel.getStartTime() < fDataModel.getEndTime()) && + fScaledData != null && event.x >= 0 && event.x - fOffset < fScaledData.fWidth) { + fillTooltip(event.x - fOffset); + } + fCanvas.setToolTipText(null); + } + + private void fillTooltip(final int index) { + long startTime = fScaledData.getBucketStartTime(index); + /* + * negative values are possible if time values came into the model + * in decreasing order + */ + if (startTime < 0) { + startTime = 0; + } + final long endTime = fScaledData.getBucketEndTime(index); + final int nbEvents = (index >= 0) ? fScaledData.fData[index].getNbEvents() : 0; + int selectionBeginBucket = Math.min(fScaledData.fSelectionBeginBucket, fScaledData.fSelectionEndBucket); + int selectionEndBucket = Math.max(fScaledData.fSelectionBeginBucket, fScaledData.fSelectionEndBucket); + if (selectionBeginBucket <= index && index <= selectionEndBucket && fSelectionBegin != fSelectionEnd) { + long start = Math.abs(fSelectionEnd - fSelectionBegin); + TmfTimestampDelta delta = new TmfTimestampDelta(start, ITmfTimestamp.NANOSECOND_SCALE); + addItem(null, Messages.Histogram_selectionSpanToolTip, delta.toString()); + } + addItem(null, ToolTipString.fromString(Messages.Histogram_bucketRangeToolTip), + ToolTipString.fromTimestamp(NLS.bind(Messages.Histogram_timeRange, + TmfTimestamp.fromNanos(startTime).toString(), TmfTimestamp.fromNanos(endTime).toString()), startTime)); + addItem(null, Messages.Histogram_eventCountToolTip, Long.toString(nbEvents)); + if (!HistogramScaledData.hideLostEvents) { + final int nbLostEvents = (index >= 0) ? fScaledData.fLostEventsData[index] : 0; + addItem(null, Messages.Histogram_lostEventCountToolTip, Long.toString(nbLostEvents)); + } + } + }; // ------------------------------------------------------------------------ // Construction @@ -278,7 +321,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi fCanvas.addMouseListener(this); fCanvas.addMouseTrackListener(this); fCanvas.addMouseMoveListener(this); - + fToolTipHandler.activateHoverHelp(fCanvas); TmfSignalManager.register(this); } @@ -338,6 +381,8 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi fTimeLineScale.setHeight(TIME_SCALE_HEIGHT); fTimeLineScale.setTimeProvider(new HistogramTimeAdapter(fDataModel)); + updateTimeFormat(); + return composite; } @@ -986,46 +1031,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi @Override public void mouseHover(final MouseEvent event) { - if ((fDataModel.getNbEvents() != 0 || fDataModel.getStartTime() < fDataModel.getEndTime()) && - fScaledData != null && event.x >= 0 && event.x - fOffset < fScaledData.fWidth) { - final String tooltip = formatToolTipLabel(event.x - fOffset); - fCanvas.setToolTipText(tooltip); - return; - } - fCanvas.setToolTipText(null); - } - - private String formatToolTipLabel(final int index) { - long startTime = fScaledData.getBucketStartTime(index); - /* - * negative values are possible if time values came into the model in - * decreasing order - */ - if (startTime < 0) { - startTime = 0; - } - final long endTime = fScaledData.getBucketEndTime(index); - final int nbEvents = (index >= 0) ? fScaledData.fData[index].getNbEvents() : 0; - final String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ - final StringBuffer buffer = new StringBuffer(); - int selectionBeginBucket = Math.min(fScaledData.fSelectionBeginBucket, fScaledData.fSelectionEndBucket); - int selectionEndBucket = Math.max(fScaledData.fSelectionBeginBucket, fScaledData.fSelectionEndBucket); - if (selectionBeginBucket <= index && index <= selectionEndBucket && fSelectionBegin != fSelectionEnd) { - TmfTimestampDelta delta = new TmfTimestampDelta(Math.abs(fSelectionEnd - fSelectionBegin), ITmfTimestamp.NANOSECOND_SCALE); - buffer.append(NLS.bind(Messages.Histogram_selectionSpanToolTip, delta.toString())); - buffer.append(newLine); - } - buffer.append(NLS.bind(Messages.Histogram_bucketRangeToolTip, - TmfTimestamp.fromNanos(startTime).toString(), - TmfTimestamp.fromNanos(endTime).toString())); - buffer.append(newLine); - buffer.append(NLS.bind(Messages.Histogram_eventCountToolTip, nbEvents)); - if (!HistogramScaledData.hideLostEvents) { - final int nbLostEvents = (index >= 0) ? fScaledData.fLostEventsData[index] : 0; - buffer.append(newLine); - buffer.append(NLS.bind(Messages.Histogram_lostEventCountToolTip, nbLostEvents)); - } - return buffer.toString(); + // do nothing } private void updateStatusLine(long startTime, long endTime, long cursorTime) { @@ -1098,8 +1104,18 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi */ @TmfSignalHandler public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal) { + updateTimeFormat(); fTimeLineScale.redraw(); fComposite.layout(); } + private void updateTimeFormat() { + HistogramTimeAdapter timeProvider = (HistogramTimeAdapter) fTimeLineScale.getTimeProvider(); + String datime = TmfTimePreferences.getPreferenceMap().get(ITmfTimePreferencesConstants.DATIME); + if (ITmfTimePreferencesConstants.TIME_ELAPSED_FMT.equals(datime)) { + timeProvider.setTimeFormat(TimeFormat.RELATIVE); + } else { + timeProvider.setTimeFormat(TimeFormat.CALENDAR); + } + } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java index 53160fe747..9dcc4a37ab 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 Ericsson + * Copyright (c) 2009, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -57,7 +57,6 @@ import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; -import org.eclipse.tracecompass.tmf.core.signal.TmfSignalThrottler; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal; @@ -72,6 +71,7 @@ import org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo; import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal; +import org.eclipse.tracecompass.tmf.ui.signal.TmfUiSignalThrottler; import org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned; import org.eclipse.tracecompass.tmf.ui.views.TmfView; import org.eclipse.ui.IActionBars; @@ -151,8 +151,8 @@ public class HistogramView extends TmfView implements ITmfTimeAligned { private Image[] fLegendImages; // Throttlers for the time sync and time-range sync signals - private final TmfSignalThrottler fTimeSyncThrottle; - private final TmfSignalThrottler fTimeRangeSyncThrottle; + private final TmfUiSignalThrottler fTimeSyncThrottle; + private final TmfUiSignalThrottler fTimeRangeSyncThrottle; // Action for toggle showing the lost events private Action hideLostEventsAction; @@ -168,8 +168,8 @@ public class HistogramView extends TmfView implements ITmfTimeAligned { */ public HistogramView() { super(ID); - fTimeSyncThrottle = new TmfSignalThrottler(this, 200); - fTimeRangeSyncThrottle = new TmfSignalThrottler(this, 200); + fTimeSyncThrottle = new TmfUiSignalThrottler(this, 200); + fTimeRangeSyncThrottle = new TmfUiSignalThrottler(this, 200); } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Messages.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Messages.java index 95bb164796..e357e4f9b1 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Messages.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Messages.java @@ -60,6 +60,11 @@ public class Messages extends NLS { */ public static String Histogram_bucketRangeToolTip; /** + * Tool tip formatter for time range + * @since 5.0 + */ + public static String Histogram_timeRange; + /** * The tool tip text for the event count. */ public static String Histogram_eventCountToolTip; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/messages.properties b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/messages.properties index 226641b50b..d12fa8a09e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/messages.properties +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/messages.properties @@ -15,7 +15,8 @@ HistogramView_showTraces=Activate Trace Coloring HistogramView_selectionStartLabel=Selection Start HistogramView_selectionEndLabel=Selection End HistogramView_windowSpanLabel=Window Span -Histogram_selectionSpanToolTip=Selection Span = {0} -Histogram_bucketRangeToolTip=Bucket Range = [{0}, {1}) -Histogram_eventCountToolTip=Event count = {0} -Histogram_lostEventCountToolTip=Lost event count = {0} +Histogram_selectionSpanToolTip=Selection Span +Histogram_bucketRangeToolTip=Bucket Range +Histogram_timeRange=[{0} - {1}) +Histogram_eventCountToolTip=Event count +Histogram_lostEventCountToolTip=Lost event count diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java index bfa342f728..4b21836b14 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2016 Ericsson + * Copyright (c) 2010, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -35,12 +35,15 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfEventFilterAppliedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfEventSearchAppliedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; +import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimePreferences; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; @@ -105,7 +108,6 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I fViewer = new TimeGraphViewer(parent, SWT.NONE); fPresentationProvider = new TimeChartAnalysisProvider(); fViewer.setTimeGraphProvider(fPresentationProvider); - fViewer.setTimeFormat(TimeFormat.CALENDAR); fViewer.addTimeListener(this); fViewer.addRangeListener(this); fViewer.addSelectionListener(this); @@ -126,6 +128,8 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I ColorSettingsManager.addColorSettingsListener(this); ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); + + updateTimeFormat(); } @Override @@ -789,6 +793,28 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I } /** + * Handler for the Timestamp Format Updated signal + * + * @param signal + * the format of the timestamps was updated. + * @since 5.0 + */ + @TmfSignalHandler + public void updateTimeFormat(final TmfTimestampFormatUpdateSignal signal) { + updateTimeFormat(); + fViewer.refresh(); + } + + private void updateTimeFormat() { + String datime = TmfTimePreferences.getPreferenceMap().get(ITmfTimePreferencesConstants.DATIME); + if (ITmfTimePreferencesConstants.TIME_ELAPSED_FMT.equals(datime)) { + fViewer.setTimeFormat(TimeFormat.RELATIVE); + } else { + fViewer.setTimeFormat(TimeFormat.CALENDAR); + } + } + + /** * @since 1.0 */ @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java index 0144b34534..c3232e9dce 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2018 Ericsson, École Polytechnique de Montréal and others + * Copyright (c) 2012, 2019 Ericsson, École Polytechnique de Montréal and others * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -127,7 +127,9 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimePreferences; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; @@ -187,6 +189,7 @@ import org.eclipse.ui.progress.IWorkbenchSiteProgressService; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; @@ -315,6 +318,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA private int fAutoExpandLevel = ALL_LEVELS; + private @Nullable TimeFormat fTimeFormat = null; + /** The default column index for sorting */ private int fInitialSortColumn = 0; @@ -814,7 +819,11 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA } private static Predicate<@NonNull Map<@NonNull String, @NonNull String>> multiToMapPredicate(@NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull String>> predicate) { - return map -> predicate.test(Objects.requireNonNull(ImmutableMultimap.copyOf(map.entrySet()))); + return map -> { + Builder<@NonNull String, @NonNull String> builder = ImmutableMultimap.builder(); + map.forEach((key, value) -> builder.put(key, value)); + return predicate.test(Objects.requireNonNull(builder.build())); + }; } /** @@ -1111,6 +1120,22 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA } /** + * Sets the time format, or null to use the Time Format 'Date and Time + * format' preference (default). + * + * @param timeFormat + * the {@link TimeFormat} used to display timestamps + * @since 5.0 + */ + protected void setTimeFormat(TimeFormat timeFormat) { + fTimeFormat = timeFormat; + if (fTimeGraphViewer != null) { + updateTimeFormat(); + fTimeGraphViewer.refresh(); + } + } + + /** * Gets the entry list for a trace * * @param trace @@ -1388,8 +1413,6 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA } }); - timeGraphViewer.setTimeFormat(TimeFormat.CALENDAR); - IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager(); timeGraphControl.setStatusLineManager(statusLineManager); @@ -1433,6 +1456,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA activateContextService(); } }); + + updateTimeFormat(); } private void activateContextService() { @@ -1693,6 +1718,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA */ @TmfSignalHandler public void updateTimeFormat(final TmfTimestampFormatUpdateSignal signal) { + updateTimeFormat(); fTimeGraphViewer.refresh(); } @@ -1714,6 +1740,19 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA // Internal // ------------------------------------------------------------------------ + private void updateTimeFormat() { + if (fTimeFormat == null) { + String datime = TmfTimePreferences.getPreferenceMap().get(ITmfTimePreferencesConstants.DATIME); + if (ITmfTimePreferencesConstants.TIME_ELAPSED_FMT.equals(datime)) { + fTimeGraphViewer.setTimeFormat(TimeFormat.RELATIVE); + } else { + fTimeGraphViewer.setTimeFormat(TimeFormat.CALENDAR); + } + } else { + fTimeGraphViewer.setTimeFormat(fTimeFormat); + } + } + private void loadTrace(final ITmfTrace trace) { if (fZoomThread != null) { fZoomThread.cancel(); @@ -2653,7 +2692,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA */ private void setGlobalRegexFilter(Collection<@NonNull String> regexes) { fGlobalFilter = regexes; - globalFilterUpdated(); + // Make sure the update is done in the UI thread + Display.getDefault().asyncExec(() -> globalFilterUpdated()); } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/BaseDataProviderTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/BaseDataProviderTimeGraphView.java index c5177ea16b..573a4206ea 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/BaseDataProviderTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/BaseDataProviderTimeGraphView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Ericsson + * Copyright (c) 2018, 2019 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -51,6 +51,7 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent; import com.google.common.collect.HashBasedTable; import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; import com.google.common.collect.Table; @@ -150,6 +151,8 @@ public class BaseDataProviderTimeGraphView extends AbstractTimeGraphView { if (uiEntry != null) { uiEntry.updateModel(entry); } else { + // Do not assume that parentless entries are + // trace entries uiEntry = new TraceEntry(entry, trace, dataProvider); fEntries.put(dataProvider, entry.getId(), uiEntry); addToEntryList(parentTrace, Collections.singletonList(uiEntry)); @@ -160,7 +163,11 @@ public class BaseDataProviderTimeGraphView extends AbstractTimeGraphView { long start = getStartTime(); long end = getEndTime(); final long resolution = Long.max(1, (end - start) / getDisplayWidth()); - zoomEntries(fEntries.values(), start, end, resolution, monitor); + @NonNull Iterable<@NonNull TimeGraphEntry> entries; + synchronized (fEntries) { + entries = ImmutableList.copyOf(fEntries.values()); + } + zoomEntries(entries, start, end, resolution, monitor); } if (monitor.isCanceled()) { @@ -184,8 +191,9 @@ public class BaseDataProviderTimeGraphView extends AbstractTimeGraphView { } /** - * Class to encapsulate a {@link TimeGraphEntryModel} for the trace level and - * the relevant data provider + * Class to represent a parent entry, for which we keep a link to the trace + * and data provider to avoid having to do so for its children. This type of + * entry is otherwise not different from any other time graph entry. * * @author Loic Prieur-Drevon * @since 3.3 @@ -211,11 +219,6 @@ public class BaseDataProviderTimeGraphView extends AbstractTimeGraphView { fProvider = provider; } - @Override - public boolean hasTimeEvents() { - return false; - } - /** * Getter for this trace entry's trace * @@ -332,7 +335,10 @@ public class BaseDataProviderTimeGraphView extends AbstractTimeGraphView { private void zoomEntries(Map<Long, TimeGraphEntry> map, List<ITimeGraphRowModel> model, boolean completed, Sampling sampling) { boolean isZoomThread = Thread.currentThread() instanceof ZoomThread; for (ITimeGraphRowModel rowModel : model) { - TimeGraphEntry entry = map.get(rowModel.getEntryID()); + TimeGraphEntry entry; + synchronized (fEntries) { + entry = map.get(rowModel.getEntryID()); + } if (entry != null) { List<ITimeEvent> events = createTimeEvents(entry, rowModel.getStates()); @@ -396,10 +402,10 @@ public class BaseDataProviderTimeGraphView extends AbstractTimeGraphView { * @since 3.3 */ protected TimeEvent createTimeEvent(TimeGraphEntry entry, ITimeGraphState state) { - if (state.getValue() == Integer.MIN_VALUE) { + String label = state.getLabel(); + if (state.getValue() == Integer.MIN_VALUE && label == null) { return new NullTimeEvent(entry, state.getStartTime(), state.getDuration()); } - String label = state.getLabel(); if (label != null) { return new NamedTimeEvent(entry, state.getStartTime(), state.getDuration(), state.getValue(), label, state.getActiveProperties()); } @@ -424,8 +430,12 @@ public class BaseDataProviderTimeGraphView extends AbstractTimeGraphView { if (model != null) { for (ITimeGraphArrow arrow : model) { - ITimeGraphEntry prevEntry = fEntries.get(provider, arrow.getSourceId()); - ITimeGraphEntry nextEntry = fEntries.get(provider, arrow.getDestinationId()); + ITimeGraphEntry prevEntry; + ITimeGraphEntry nextEntry; + synchronized (fEntries) { + prevEntry = fEntries.get(provider, arrow.getSourceId()); + nextEntry = fEntries.get(provider, arrow.getDestinationId()); + } if (prevEntry != null && nextEntry != null) { linkList.add(new TimeLinkEvent(prevEntry, nextEntry, arrow.getStartTime(), arrow.getDuration(), arrow.getValue())); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/TimeGraphLegend.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/TimeGraphLegend.java index 9ad430d029..e1bae22236 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/TimeGraphLegend.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/TimeGraphLegend.java @@ -271,6 +271,10 @@ public class TimeGraphLegend extends TitleAreaDialog { * @since 3.3 */ protected class LegendEntry extends Composite { + /** + * ID to identify a control as part of a given entry + */ + private static final String LEGEND_ENTRY_KEY = "legend.entry.key"; //$NON-NLS-1$ private final Swatch fBar; private final Scale fScale; private final Button fReset; @@ -292,6 +296,7 @@ public class TimeGraphLegend extends TitleAreaDialog { String name = si.getStateString(); setLayout(GridLayoutFactory.swtDefaults().numColumns(4).create()); fBar = new Swatch(this, si.getStateColor()); + fBar.setData(LEGEND_ENTRY_KEY, name); fBar.setToolTipText(Messages.TimeGraphLegend_swatchClick); fBar.addMouseListener(new MouseAdapter() { @@ -347,6 +352,7 @@ public class TimeGraphLegend extends TitleAreaDialog { return text; } }; + label.setData(LEGEND_ENTRY_KEY, name); label.setText(name); label.setLayoutData(GridDataFactory.fillDefaults().hint(160, SWT.DEFAULT).align(SWT.FILL, SWT.CENTER).grab(true, false).create()); fScale = new Scale(this, SWT.NONE); @@ -354,6 +360,7 @@ public class TimeGraphLegend extends TitleAreaDialog { fScale.setMinimum(1); fScale.setSelection((int) (100 * si.getStateHeightFactor())); fScale.setToolTipText(Messages.TimeGraphLegend_widthTooltip); + fScale.setData(LEGEND_ENTRY_KEY, name); fScale.addSelectionListener(new SelectionListener() { @Override @@ -372,6 +379,7 @@ public class TimeGraphLegend extends TitleAreaDialog { }); fScale.setLayoutData(GridDataFactory.swtDefaults().hint(120, SWT.DEFAULT).create()); fReset = new Button(this, SWT.FLAT); + fReset.setData(LEGEND_ENTRY_KEY, name); fReset.addSelectionListener(new SelectionListener() { @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java index 84148c7a82..08f039914c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2007, 2018 Intel Corporation and others + * Copyright (c) 2007, 2019 Intel Corporation and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -3217,15 +3217,9 @@ public class TimeGraphControl extends TimeGraphBaseControl return; } } - if (fTimeProvider == null || - fTimeProvider.getTime0() == fTimeProvider.getTime1() || - getSize().x - fTimeProvider.getNameSpace() <= 0) { - return; - } - int idx; if (1 == e.button && ((e.stateMask & SWT.MODIFIER_MASK) == 0 || (e.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT)) { int nameSpace = fTimeProvider.getNameSpace(); - idx = getItemIndexAtY(e.y); + int idx = getItemIndexAtY(e.y); if (idx >= 0) { Item item = fItemData.fExpandedItems[idx]; if (item.fHasChildren && e.x < nameSpace && e.x < MARGIN + (item.fLevel + 1) * EXPAND_SIZE) { @@ -3238,6 +3232,17 @@ public class TimeGraphControl extends TimeGraphBaseControl selectItem(idx, false); // clear selection fireSelectionChanged(); } + } else if (3 == e.button && e.x < fTimeProvider.getNameSpace()) { + int idx = getItemIndexAtY(e.y); + selectItem(idx, false); + fireSelectionChanged(); + } + if (fTimeProvider == null || + fTimeProvider.getTime0() == fTimeProvider.getTime1() || + getSize().x - fTimeProvider.getNameSpace() <= 0) { + return; + } + if (1 == e.button && ((e.stateMask & SWT.MODIFIER_MASK) == 0 || (e.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT)) { long hitTime = getTimeAtX(e.x); if (hitTime >= 0) { setCapture(true); @@ -3294,22 +3299,16 @@ public class TimeGraphControl extends TimeGraphBaseControl fTime1bak = fTimeProvider.getTime1(); updateCursor(e.x, e.stateMask); } - } else if (3 == e.button) { - if (e.x >= fTimeProvider.getNameSpace()) { - setCapture(true); - fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), getSize().x - RIGHT_MARGIN); - fDragX0 = fDragX; - fDragTime0 = getTimeAtX(fDragX0); - fDragState = DRAG_ZOOM; - fDragButton = e.button; - redraw(); - updateCursor(e.x, e.stateMask); - fTimeGraphScale.setDragRange(fDragX0, fDragX); - } else { - idx = getItemIndexAtY(e.y); - selectItem(idx, false); - fireSelectionChanged(); - } + } else if (3 == e.button && e.x >= fTimeProvider.getNameSpace()) { + setCapture(true); + fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), getSize().x - RIGHT_MARGIN); + fDragX0 = fDragX; + fDragTime0 = getTimeAtX(fDragX0); + fDragState = DRAG_ZOOM; + fDragButton = e.button; + redraw(); + updateCursor(e.x, e.stateMask); + fTimeGraphScale.setDragRange(fDragX0, fDragX); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java index 69c4bcf76c..8b37f7ae3f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2007, 2018 Intel Corporation, Ericsson + * Copyright (c) 2007, 2019 Intel Corporation, Ericsson * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,6 +46,10 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent; */ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { + private static final String ROW_CATEGORY = "Row"; //$NON-NLS-1$ + private static final String MARKER_CATEGORY_PREFIX = "Marker "; //$NON-NLS-1$ + private static final String LINK_CATEGORY = "Link"; //$NON-NLS-1$ + private static final String STATE_CATEGORY = "State"; //$NON-NLS-1$ private static final String MARKER_OFFSET = " "; //$NON-NLS-1$ private static final String MIN_STRING = "< 0.01%"; //$NON-NLS-1$ @@ -72,8 +76,8 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { public TimeGraphTooltipHandler(ITimeGraphPresentationProvider graphProv, ITimeDataProvider timeProv) { - this.fTimeGraphProvider = graphProv; - this.fTimeDataProvider = timeProv; + fTimeGraphProvider = graphProv; + fTimeDataProvider = timeProv; } /** @@ -102,8 +106,10 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { } fillValues(pt, timeGraphControl, entry); Iterable<IMarkerEvent> markers = getMarkers(timeGraphControl, entry, pt); + int i = 0; for (IMarkerEvent marker : markers) { - fillValues(marker); + fillValues(MARKER_CATEGORY_PREFIX + i, marker); + i++; } } } @@ -140,22 +146,22 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { return retVal; } - private void fillValues(IMarkerEvent marker) { + private void fillValues(String itemName, IMarkerEvent marker) { Map<String, String> toolTips = fTimeGraphProvider.getEventHoverToolTipInfo(marker); String category = marker.getCategory(); String label = marker.getLabel(); - addItem(category == null ? Messages.TimeGraphTooltipHandler_DefaultMarkerName : category, label == null ? "" : label); //$NON-NLS-1$ + addItem(itemName, category == null ? Messages.TimeGraphTooltipHandler_DefaultMarkerName : category, label == null ? "" : label); //$NON-NLS-1$ long timestamp = marker.getTime(); long duration = marker.getDuration(); if (duration == 0) { - addItem(MARKER_OFFSET + Messages.TimeGraphTooltipHandler_Timestamp, TmfTimestamp.fromNanos(timestamp).toString()); + addItem(ToolTipString.fromString(itemName), ToolTipString.fromString(MARKER_OFFSET + Messages.TimeGraphTooltipHandler_Timestamp), ToolTipString.fromTimestamp(TmfTimestamp.fromNanos(timestamp).toString(), timestamp)); } else { - addItem(MARKER_OFFSET + Messages.TimeGraphTooltipHandler_StartTime, TmfTimestamp.fromNanos(timestamp).toString()); - addItem(MARKER_OFFSET + Messages.TimeGraphTooltipHandler_EndTime, TmfTimestamp.fromNanos(timestamp + duration).toString()); + addItem(ToolTipString.fromString(itemName), ToolTipString.fromString(MARKER_OFFSET + Messages.TimeGraphTooltipHandler_StartTime), ToolTipString.fromTimestamp(TmfTimestamp.fromNanos(timestamp).toString(), timestamp)); + addItem(ToolTipString.fromString(itemName), ToolTipString.fromString(MARKER_OFFSET + Messages.TimeGraphTooltipHandler_EndTime), ToolTipString.fromTimestamp(TmfTimestamp.fromNanos(timestamp + duration).toString(), timestamp + duration)); } if (toolTips != null) { for (Entry<String, String> tooltip : toolTips.entrySet()) { - addItem(MARKER_OFFSET + tooltip.getKey(), tooltip.getValue()); // $NON-NLS-1$ + addItem(itemName, MARKER_OFFSET + tooltip.getKey(), tooltip.getValue()); // $NON-NLS-1$ } } } @@ -174,10 +180,10 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { ITimeEvent nextEvent = Utils.findEvent(entry, currPixelTime, 1); /* - * if there is no current event at the start of the current - * pixel range, or if the current event starts before the - * current pixel range, use the next event as long as it - * starts within the current pixel range + * if there is no current event at the start of the current pixel + * range, or if the current event starts before the current pixel + * range, use the next event as long as it starts within the current + * pixel range */ if ((currEvent == null || currEvent.getTime() < currPixelTime) && (nextEvent != null && nextEvent.getTime() < nextPixelTime)) { @@ -186,9 +192,9 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { } /* - * if there is still no current event, use the closest - * between the next and previous event, as long as they are - * within a distance threshold + * if there is still no current event, use the closest between the + * next and previous event, as long as they are within a distance + * threshold */ if (currEvent == null || currEvent instanceof NullTimeEvent) { int nextDelta = Integer.MAX_VALUE; @@ -221,7 +227,7 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { } if (!entryName.isEmpty()) { - addItem(stateTypeName, entry.getName()); + addItem(ROW_CATEGORY, stateTypeName, entry.getName()); } if (currEvent == null || currEvent instanceof NullTimeEvent) { @@ -231,7 +237,7 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { // state String state = fTimeGraphProvider.getEventName(currEvent); if (state != null) { - addItem(Messages.TmfTimeTipHandler_TRACE_STATE, state); + addItem(STATE_CATEGORY, Messages.TmfTimeTipHandler_TRACE_STATE, state); } // This block receives a list of <String, String> values to @@ -239,7 +245,7 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { Map<String, String> eventAddOns = fTimeGraphProvider.getEventHoverToolTipInfo(currEvent, currPixelTime); if (eventAddOns != null) { for (Entry<String, String> eventAddOn : eventAddOns.entrySet()) { - addItem(eventAddOn.getKey(), eventAddOn.getValue()); + addItem(STATE_CATEGORY, eventAddOn.getKey(), eventAddOn.getValue()); } } if (fTimeGraphProvider.displayTimesInTooltip()) { @@ -286,18 +292,18 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { } } if (tf == TimeFormat.CALENDAR) { - addItem(Messages.TmfTimeTipHandler_TRACE_DATE, + addItem(STATE_CATEGORY, Messages.TmfTimeTipHandler_TRACE_DATE, eventStartTime > -1 ? FormatTimeUtils.formatDate(eventStartTime) : "?"); //$NON-NLS-1$ } if (eventDuration > 0) { - addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME, startTime); - addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME, endTime); + addItem(ToolTipString.fromString(STATE_CATEGORY), ToolTipString.fromString(Messages.TmfTimeTipHandler_TRACE_START_TIME), ToolTipString.fromTimestamp(startTime, eventStartTime)); + addItem(ToolTipString.fromString(STATE_CATEGORY), ToolTipString.fromString(Messages.TmfTimeTipHandler_TRACE_STOP_TIME), ToolTipString.fromTimestamp(endTime, eventEndTime)); } else { - addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME, startTime); + addItem(ToolTipString.fromString(STATE_CATEGORY), ToolTipString.fromString(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME), ToolTipString.fromTimestamp(startTime, eventStartTime)); } if (eventDuration > 0) { - addItem(Messages.TmfTimeTipHandler_DURATION, duration); + addItem(STATE_CATEGORY, Messages.TmfTimeTipHandler_DURATION, duration); long begin = fTimeDataProvider.getSelectionBegin(); long end = fTimeDataProvider.getSelectionEnd(); final long delta = Math.abs(end - begin); @@ -312,7 +318,7 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { percentage = String.format("%,.2f%%", durationRatio * 100.0); //$NON-NLS-1$ } - addItem(Messages.TmfTimeTipHandler_PERCENT_OF_SELECTION, percentage); + addItem(STATE_CATEGORY, Messages.TmfTimeTipHandler_PERCENT_OF_SELECTION, percentage); } } } @@ -320,15 +326,15 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { } private void fillValues(ILinkEvent linkEvent) { - addItem(Messages.TmfTimeTipHandler_LINK_SOURCE, linkEvent.getEntry().getName()); - addItem(Messages.TmfTimeTipHandler_LINK_TARGET, linkEvent.getDestinationEntry().getName()); + addItem(LINK_CATEGORY, Messages.TmfTimeTipHandler_LINK_SOURCE, linkEvent.getEntry().getName()); + addItem(LINK_CATEGORY, Messages.TmfTimeTipHandler_LINK_TARGET, linkEvent.getDestinationEntry().getName()); // This block receives a list of <String, String> values to be // added to the tip table Map<String, String> eventAddOns = fTimeGraphProvider.getEventHoverToolTipInfo(linkEvent); if (eventAddOns != null) { for (Entry<String, String> eventAddOn : eventAddOns.entrySet()) { - addItem(eventAddOn.getKey(), eventAddOn.getValue()); + addItem(LINK_CATEGORY, eventAddOn.getKey(), eventAddOn.getValue()); } } if (fTimeGraphProvider.displayTimesInTooltip()) { @@ -344,14 +350,14 @@ public class TimeGraphTooltipHandler extends TmfAbstractToolTipHandler { Resolution res = Resolution.NANOSEC; TimeFormat tf = fTimeDataProvider.getTimeFormat().convert(); if (tf == TimeFormat.CALENDAR) { - addItem(Messages.TmfTimeTipHandler_TRACE_DATE, FormatTimeUtils.formatDate(sourceTime)); + addItem(LINK_CATEGORY, Messages.TmfTimeTipHandler_TRACE_DATE, FormatTimeUtils.formatDate(sourceTime)); } if (duration > 0) { - addItem(Messages.TmfTimeTipHandler_LINK_SOURCE_TIME, FormatTimeUtils.formatTime(sourceTime, tf, res)); - addItem(Messages.TmfTimeTipHandler_LINK_TARGET_TIME, FormatTimeUtils.formatTime(targetTime, tf, res)); - addItem(Messages.TmfTimeTipHandler_DURATION, FormatTimeUtils.formatDelta(duration, tf, res)); + addItem(ToolTipString.fromString(LINK_CATEGORY), ToolTipString.fromString(Messages.TmfTimeTipHandler_LINK_SOURCE_TIME), ToolTipString.fromTimestamp(FormatTimeUtils.formatTime(sourceTime, tf, res), sourceTime)); + addItem(ToolTipString.fromString(LINK_CATEGORY), ToolTipString.fromString(Messages.TmfTimeTipHandler_LINK_TARGET_TIME), ToolTipString.fromTimestamp(FormatTimeUtils.formatTime(targetTime, tf, res), targetTime)); + addItem(LINK_CATEGORY, Messages.TmfTimeTipHandler_DURATION, FormatTimeUtils.formatDelta(duration, tf, res)); } else { - addItem(Messages.TmfTimeTipHandler_LINK_TIME, FormatTimeUtils.formatTime(sourceTime, tf, res)); + addItem(ToolTipString.fromString(LINK_CATEGORY), ToolTipString.fromString(Messages.TmfTimeTipHandler_LINK_TIME), ToolTipString.fromTimestamp(FormatTimeUtils.formatTime(sourceTime, tf, res), sourceTime)); } } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/Utils.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/Utils.java index 1d582fb6ad..d622f8087f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/Utils.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/Utils.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2007, 2018 Intel Corporation, Ericsson + * Copyright (c) 2007, 2019 Intel Corporation, Ericsson * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -71,6 +71,7 @@ public class Utils { /** * Timestamp displayed as percentages, where 100% maps to the long value * {@link LongToPercentFormat#MAX_PERCENT_VALUE} + * * @since 4.0 */ PERCENTAGE((FormatTimeUtils.TimeFormat.PERCENTAGE)); @@ -79,14 +80,36 @@ public class Utils { private TimeFormat(FormatTimeUtils.TimeFormat tf) { this.tf = tf; } + /** - * Convert the {@link TimeFormat} to a {@link org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.TimeFormat} + * Convert this {@link TimeFormat} to a + * {@link org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.TimeFormat} + * * @return the converted time format * @since 3.3 */ public FormatTimeUtils.TimeFormat convert() { return tf; } + + /** + * Convert the specified + * {@link org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.TimeFormat} + * to a {@link TimeFormat} + * + * @param timeFormat + * the time format + * @return the converted time format + * @since 5.0 + */ + public static TimeFormat convert(FormatTimeUtils.TimeFormat timeFormat) { + for (TimeFormat format : values()) { + if (format.tf == timeFormat) { + return format; + } + } + return null; + } } /** |