Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 58831 Details for
Bug 167609
Enhance Thread Statistics View
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch created by Eclipse-CVS
org.eclipse.tptp.trace.jvmti.client_20070213-patch (text/plain), 123.05 KB, created by
Ruslan Scherbakov
on 2007-02-13 01:54:04 EST
(
hide
)
Description:
Patch created by Eclipse-CVS
Filename:
MIME Type:
Creator:
Ruslan Scherbakov
Created:
2007-02-13 01:54:04 EST
Size:
123.05 KB
patch
obsolete
>Index: plugin.properties >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/plugin.properties,v >retrieving revision 1.5 >diff -u -r1.5 plugin.properties >--- plugin.properties 14 Nov 2006 19:11:08 -0000 1.5 >+++ plugin.properties 13 Feb 2007 06:39:25 -0000 >@@ -23,4 +23,8 @@ > JVMTI_ANALYSIS_TYPE_VIEW_UML_CLASS = UML2 Class Interactions > JVMTI_ANALYSIS_TYPE_THRD_DESCRIPTION_TYPE = Thread Statistics > JVMTI_ANALYSIS_TYPE_HEAP_DESCRIPTION_TYPE = Memory Statistics >+JVMTI_ANALYSIS_TYPE_THREAD_STATES_DESCRIPTION_TYPE = Thread States >+JVMTI_ANALYSIS_TYPE_CALL_STACK_DESCRIPTION_TYPE = Call Stack > JVMTI_ANALYSIS_TYPE_THRD_TOOLTIP = Open Thread Statistics >+JVMTI_ANALYSIS_TYPE_THREAD_STATES_TOOLTIP = Open Thread States >+JVMTI_ANALYSIS_TYPE_CALL_STACK_TOOLTIP = Open Call Stack >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/plugin.xml,v >retrieving revision 1.6 >diff -u -r1.6 plugin.xml >--- plugin.xml 14 Nov 2006 19:11:09 -0000 1.6 >+++ plugin.xml 13 Feb 2007 06:39:25 -0000 >@@ -90,6 +90,12 @@ > id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatisticViewAction" > name="%JVMTI_ANALYSIS_TYPE_THRD_DESCRIPTION_TYPE" > type="org.eclipse.tptp.analysisType.jvmti.thread"/> >+ <analyzerExtension >+ class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatesViewAction" >+ extension="trace" >+ id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatesViewAction" >+ name="%JVMTI_ANALYSIS_TYPE_THREAD_STATES_DESCRIPTION_TYPE"> >+ </analyzerExtension> > </extension> > > <extension >@@ -101,6 +107,17 @@ > class="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatisticViewer" > id="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatisticViewer"> > </view> >+ <view >+ category="org.eclipse.hyades.trace.internal.ui.trace" >+ class="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatesViewer" >+ id="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatesViewer" >+ name="%JVMTI_ANALYSIS_TYPE_THREAD_STATES_DESCRIPTION_TYPE"/> >+ <view >+ category="org.eclipse.hyades.trace.internal.ui.trace" >+ class="org.eclipse.tptp.trace.jvmti.internal.client.views.CallStackViewer" >+ id="org.eclipse.tptp.trace.jvmti.internal.client.views.CallStackView" >+ name="%JVMTI_ANALYSIS_TYPE_CALL_STACK_DESCRIPTION_TYPE"> >+ </view> > </extension> > > <extension >@@ -113,6 +130,18 @@ > relationship="stack" > id="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatisticViewer"> > </view> >+ <view >+ id="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatesViewer" >+ relationship="stack" >+ relative="org.eclipse.hyades.trace.views.adapter.internal.ExecutionStatisticViewer2" >+ visible="false"> >+ </view> >+ <view >+ id="org.eclipse.tptp.trace.jvmti.internal.client.views.CallStackViewer" >+ relationship="bottom" >+ relative="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatesViewer" >+ visible="false"> >+ </view> > </perspectiveExtension> > </extension> > >@@ -130,6 +159,21 @@ > toolbarPath="trace/group.statistic" > id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatisticViewAction"> > </action> >+ <action >+ class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatesViewAction" >+ id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatesViewAction" >+ label="%JVMTI_ANALYSIS_TYPE_THREAD_STATES_DESCRIPTION_TYPE" >+ style="push" >+ toolbarPath="trace/group.statistic" >+ tooltip="%JVMTI_ANALYSIS_TYPE_THREAD_STATES_TOOLTIP"/> >+ <action >+ class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenCallStackViewAction" >+ id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenCallStackViewAction" >+ label="%JVMTI_ANALYSIS_TYPE_CALL_STACK_DESCRIPTION_TYPE" >+ style="push" >+ toolbarPath="trace/group.statistic" >+ tooltip="%JVMTI_ANALYSIS_TYPE_CALL_STACK_TOOLTIP"> >+ </action> > </actionSet> > </extension> > >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticViewer.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticViewer.java,v >retrieving revision 1.2 >diff -u -r1.2 ThreadStatisticViewer.java >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticViewer.java 14 Nov 2006 19:11:10 -0000 1.2 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticViewer.java 13 Feb 2007 06:39:26 -0000 >@@ -25,15 +25,17 @@ > import org.eclipse.jface.action.MenuManager; > import org.eclipse.tptp.platform.common.ui.internal.CommonUIConstants; > >-public class ThreadStatisticViewer extends TraceViewer implements IContextViewer { >+public class ThreadStatisticViewer extends TraceViewer implements >+ IContextViewer { > >- protected Action _chooseColumns; >+ protected Action _chooseColumns; > protected Action _sortByColumn; >+ protected Action _openCallStackView; > protected ContextSelectionMenuListener _contextSelectionMenuListener; >- >+ > protected String _context; > protected boolean _contextChanged; >- >+ > public ThreadStatisticViewer() { > super(); > } >@@ -49,15 +51,15 @@ > * return the view title > */ > public String getViewTitle() { >- return UIMessages.TITLE; >+ return UIMessages.THREAD_STATISTIC_TITLE; > } >- >+ > /** > * Returns the default page message. > * > */ > public String getDefaultPageMessage() { >- >+ > return UIMessages._269; > } > >@@ -68,7 +70,7 @@ > public ContextSelectionMenuListener getContextSelectionMenuListener() { > if (_contextSelectionMenuListener == null) > _contextSelectionMenuListener = new ContextSelectionMenuListener(); >- >+ > return _contextSelectionMenuListener; > } > >@@ -85,25 +87,26 @@ > _contextChanged = _context != null; > else > _contextChanged = !context.equals(_context); >- >+ > _context = context; >- >+ > if (_contextChanged && refresh && getCurrentPage() != null) >- ((TraceViewerPage)getCurrentPage()).refreshPage(); >+ ((TraceViewerPage) getCurrentPage()).refreshPage(); > } > > public void updateContext() { >- ContextUpdaterHelper.setCurrentFocusContextLanguage(getSelectedContext()); >+ ContextUpdaterHelper >+ .setCurrentFocusContextLanguage(getSelectedContext()); > _contextChanged = false; > } > >- public Object[] getViewerControls() >- { >- if (getCurrentPage() instanceof ThreadStatisticPage) { >- return new Object[] { ((ThreadStatisticPage)getCurrentPage()).getView().getTree() }; >- } >- return null; >- } >+ public Object[] getViewerControls() { >+ if (getCurrentPage() instanceof ThreadStatisticPage) { >+ return new Object[] { ((ThreadStatisticPage) getCurrentPage()) >+ .getView().getTree() }; >+ } >+ return null; >+ } > > public EObject getObjectToView(EObject selObject) { > if (selObject == null) >@@ -117,9 +120,8 @@ > TRCAgentProxy agent = (TRCAgentProxy) agents.get(idx); > if (agent == null || agent.eIsProxy()) > continue; >- if (agent >- .getType() >- .equals(CommonUIConstants.PROFILE_AGENT_TYPE)) { >+ if (agent.getType() >+ .equals(CommonUIConstants.PROFILE_AGENT_TYPE)) { > nbOfAgents++; > a = agent; > } >@@ -130,23 +132,25 @@ > } > return selObject; > } >- >+ > public void makeActions() { > super.makeActions(); > > String strChooseColumns = TraceUIMessages._56; > _chooseColumns = new Action(strChooseColumns) { > public void run() { >- ThreadStatisticPage page = (ThreadStatisticPage)getCurrentPage(); >+ ThreadStatisticPage page = (ThreadStatisticPage) getCurrentPage(); > if (page == null) { > return; > } > ThreadStatisticView view = page.getView(); >- view.getChooseColumnsAction(view.getColumnDataList(), view.getColumnsPreferencesKey()).run(); >+ view.getChooseColumnsAction(view.getColumnDataList(), >+ view.getColumnsPreferencesKey()).run(); > } > }; > _chooseColumns.setText(strChooseColumns); >- TracePluginImages.setImageDescriptors(_chooseColumns, TracePluginImages.T_LCL, TracePluginImages.IMG_CHOOSECOLUMNS); >+ TracePluginImages.setImageDescriptors(_chooseColumns, >+ TracePluginImages.T_LCL, TracePluginImages.IMG_CHOOSECOLUMNS); > _chooseColumns.setDescription(strChooseColumns); > _chooseColumns.setToolTipText(strChooseColumns); > _chooseColumns.setEnabled(true); >@@ -154,7 +158,7 @@ > String strSortByColumn = TraceUIMessages._58; > _sortByColumn = new Action(strSortByColumn) { > public void run() { >- ThreadStatisticPage page = (ThreadStatisticPage)getCurrentPage(); >+ ThreadStatisticPage page = (ThreadStatisticPage) getCurrentPage(); > if (page == null) { > return; > } >@@ -162,21 +166,25 @@ > view.getSortByColumnAction().run(); > } > }; >- >+ > _sortByColumn.setText(strSortByColumn); >- TracePluginImages.setImageDescriptors(_sortByColumn, TracePluginImages.T_LCL, TracePluginImages.IMG_SORTCOLUMNS); >+ TracePluginImages.setImageDescriptors(_sortByColumn, >+ TracePluginImages.T_LCL, TracePluginImages.IMG_SORTCOLUMNS); > _sortByColumn.setDescription(strSortByColumn); > _sortByColumn.setToolTipText(strSortByColumn); > _sortByColumn.setEnabled(true); >- >+ >+ _openCallStackView = new OpenCallStackViewAction(); >+ > IMenuManager menum = getViewSite().getActionBars().getMenuManager(); > menum.add(_chooseColumns); > menum.add(_sortByColumn); >- >+ menum.add(_openCallStackView); >+ > MenuManager submenu = new MenuManager(TraceUIMessages._222); > submenu.addMenuListener(getContextSelectionMenuListener()); > menum.add(submenu); >- >+ > getViewSite().getActionBars().updateActionBars(); > } > } >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java,v >retrieving revision 1.2 >diff -u -r1.2 UIMessages.java >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java 14 Nov 2006 19:11:12 -0000 1.2 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java 13 Feb 2007 06:39:26 -0000 >@@ -17,29 +17,27 @@ > public class UIMessages { > private static final String BUNDLE_NAME = "org.eclipse.tptp.trace.jvmti.internal.client.views.messages"; //$NON-NLS-1$ > >- public static String TITLE; >+ public static String THREAD_STATISTIC_TITLE; >+ public static String THREAD_STATES_TITLE; >+ public static String LEGEND_LABEL; >+ public static String CURRENT_TIME; >+ public static String SELECTED_TIME; >+ public static String TIME_SCALE; > > public static String _261; >- > public static String _262; >- > public static String _263; >- > public static String _264; >- > public static String _265; >- > public static String _266; >- >+ public static String _267; > public static String _269; > > private UIMessages() { > // Do not instantiate >- > } > > static { > NLS.initializeMessages(BUNDLE_NAME, UIMessages.class); > } >- > } >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticView.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticView.java,v >retrieving revision 1.2 >diff -u -r1.2 ThreadStatisticView.java >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticView.java 14 Nov 2006 18:57:47 -0000 1.2 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticView.java 13 Feb 2007 06:39:26 -0000 >@@ -57,47 +57,55 @@ > import org.eclipse.swt.widgets.TableColumn; > import org.eclipse.swt.widgets.Tree; > import org.eclipse.swt.widgets.TreeItem; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils; > > /** > * This view contains thread statistics data. > */ > public class ThreadStatisticView extends StatisticView { > >+ static final int COL_CLASS_NAME = 0; >+ static final int COL_THREAD_NAME = 1; >+ static final int COL_STATE = 2; >+ static final int COL_RUN_TIME = 3; >+ static final int COL_WAIT_TIME = 4; >+ static final int COL_BLOCK_TIME = 5; >+ static final int COL_BLOCK_COUNT = 6; >+ static final int COL_DEADLOCK_TIME = 7; >+ static final int COL_DEADLOCK_COUNT = 8; >+ > public static String PREFERENCE_KEY_PREFIX = "org.eclipse.hyades.trace.views.statistic."; > private boolean _isEmpty; > protected ContextInfoContainer _contextInfo; > > protected ColumnLabelAdapter[] _columns; >- >- public ThreadStatisticView(Composite parent, TraceViewerPage page){ >+ >+ public ThreadStatisticView(Composite parent, TraceViewerPage page) { > super(parent, page); >- >+ > createColumnsLabelProviders(); > } >- >- protected String getContextHelpId() >- { >- return TraceUIPlugin.getPluginId()+".stvw0001"; >- } >- >- public void createColumnsLabelProviders() >- { >+ >+ protected String getContextHelpId() { >+ return TraceUIPlugin.getPluginId() + ".stvw0001"; >+ } >+ >+ public void createColumnsLabelProviders() { > _columns = new ColumnLabelAdapter[] { >- new ThreadClassNameColumnLabel(), >- new ThreadNameColumnLabel(), >- new ThreadStartTimeColumnLabel(), >- new ThreadStopTimeColumnLabel(), >- new ThreadStateColumnLabel(), >- new ThreadRunningTimeColumnLabel(), >-// new ThreadSleepingTimeColumnLabel(), >- new ThreadWaitingTimeColumnLabel(), >- new ThreadBlockedTimeColumnLabel(), >- new ThreadBlockCountColumnLabel(), >- new ThreadDeadlockedTimeColumnLabel(), >- new ThreadDeadlockCountColumnLabel() >- }; >+ new ThreadClassNameColumnLabel(), >+ new ThreadNameColumnLabel(), >+ //new ThreadStartTimeColumnLabel(), >+ //new ThreadStopTimeColumnLabel(), >+ new ThreadStateColumnLabel(), >+ new ThreadRunningTimeColumnLabel(), >+ //new ThreadSleepingTimeColumnLabel(), >+ new ThreadWaitingTimeColumnLabel(), >+ new ThreadBlockedTimeColumnLabel(), >+ new ThreadBlockCountColumnLabel(), >+ new ThreadDeadlockedTimeColumnLabel(), >+ new ThreadDeadlockCountColumnLabel() }; > } >- >+ > class ThreadStatisticTreeViewer extends TreeViewer { > public ThreadStatisticTreeViewer(Composite parent) { > super(parent); >@@ -111,50 +119,47 @@ > item.setExpanded(true); > createChildren(item); > } >- >- /** >- * Returns the current selection for this provider. >- * >- * @return the current selection >- */ >- public ISelection getSelection() >- { >- ISelection sel = super.getSelection(); >- if(sel != null && !sel.isEmpty()) >- { >- Object obj = ((IStructuredSelection)sel).getFirstElement(); >- if(obj instanceof ThreadDetails) >- return new StructuredSelection(((ThreadDetails)obj).getThread()); >- } >- return sel; >- } >- >- } >- >- public class ThreadStatisticContentProvider implements ITreeContentProvider >- { >- >- public Object[] getChildren(Object element) >- { >+ >+ /** >+ * Returns the current selection for this provider. >+ * >+ * @return the current selection >+ */ >+ public ISelection getSelection() { >+ ISelection sel = super.getSelection(); >+ if (sel != null && !sel.isEmpty()) { >+ Object obj = ((IStructuredSelection) sel).getFirstElement(); >+ if (obj instanceof ThreadDetails) >+ return new StructuredSelection(((ThreadDetails) obj).getThread()); >+ } >+ return sel; >+ } >+ >+ } >+ >+ public class ThreadStatisticContentProvider implements ITreeContentProvider { >+ >+ public Object[] getChildren(Object element) { > return null; > } >- >+ > public Object getParent(Object element) { > return null; >- } >+ } > > public boolean hasChildren(Object element) { > return false; > } >- >+ > /** > * return the list of elements to display in the table tree > */ > public Object[] getElements(Object inputElement) { >- Object[] threads = PerftraceUtil.getAllThreads(_page.getMOFObject(), false); >+ Object[] threads = PerftraceUtil.getAllThreads( >+ _page.getMOFObject(), false); > Object[] elements = new Object[threads.length]; >- for (int i=0; i < threads.length; i++) { >- elements[i] = new ThreadDetails((TRCThread)threads[i]); >+ for (int i = 0; i < threads.length; i++) { >+ elements[i] = new ThreadDetails((TRCThread) threads[i]); > } > return elements; > } >@@ -165,67 +170,67 @@ > public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { > } > } >- >- public class ThreadStatisticLabelProvider extends LabelProvider >- implements ITableLabelProvider { >+ >+ public class ThreadStatisticLabelProvider extends LabelProvider implements >+ ITableLabelProvider { > protected StatisticView _viewer; >- >+ > public ThreadStatisticLabelProvider(StatisticView viewer) { > _viewer = viewer; > } > > public String getColumnText(Object obj, int col) { >- StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(_viewer.getTree().getColumn(col)); >- int pos = info.getColumnData().getInitalPos(); >- >- if (pos >= 0 && pos < _columns.length) { >- return getElementColumnText(obj, _columns[pos], info.isDeltaColumn()); >- } else { >- return ""; >- } >+ StatisticTableColumnInfo info = >+ StatisticTableColumnInfo.getStatisticTableColumnInfo(_viewer.getTree().getColumn(col)); >+ int pos = info.getColumnData().getInitalPos(); >+ >+ if (pos >= 0 && pos < _columns.length) { >+ return getElementColumnText(obj, _columns[pos], info.isDeltaColumn()); >+ } else { >+ return ""; >+ } > } >- >+ > public Image getColumnImage(Object obj, int col) { >- StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(_viewer.getTree().getColumn(col)); >- int pos = info.getColumnData().getInitalPos(); >- >- if (pos == 4) { // thread state >- >- } >- >- if(info.isDeltaColumn()) >+ StatisticTableColumnInfo info = >+ StatisticTableColumnInfo.getStatisticTableColumnInfo(_viewer.getTree().getColumn(col)); >+ int pos = info.getColumnData().getInitalPos(); >+ >+ if (pos == COL_STATE) { // thread state >+ } >+ >+ if (info.isDeltaColumn()) > return null; > >- if (pos >= 0 && pos < _columns.length) { >- return getElementColumnImage(obj, _columns[pos], info.isDeltaColumn()); >- } else { >- return null; >- } >+ if (pos >= 0 && pos < _columns.length) { >+ return getElementColumnImage(obj, _columns[pos], info.isDeltaColumn()); >+ } else { >+ return null; >+ } > } > } > > public class ThreadStatisticSorter extends StatisticSorter { >- >+ > public int compare(Viewer viewer, Object e1, Object e2) { >- if (_pos >= 0 && _pos < _columns.length) { >+ if (_pos >= 0 && _pos < _columns.length) { > return _sortSequence * compareElements(e1, e2, _columns[_pos], _info.isDeltaColumn()); >- } else { >- return 0; >- } >+ } else { >+ return 0; >+ } > } > } > >- public class ThreadStatisticFilter extends StatisticFilter{ >- >+ public class ThreadStatisticFilter extends StatisticFilter { >+ > public ThreadStatisticFilter() { > super(); > } >- >+ > public boolean select(Viewer viewer, Object parent, Object element) { >- >+ > boolean flag = true; >- String compareText = (element instanceof TRCThread) ? >- PerftraceUtil.getThreadName((TRCThread)element) : ""; >+ String compareText = (element instanceof TRCThread) ? PerftraceUtil.getThreadName((TRCThread) element) : ""; > > if (_noPattern) > return true; >@@ -259,95 +264,73 @@ > return flag; > } > } >- >- public String getDefaultColumnsTemplate() >- { >- return IContextAttributes.THREAD_CLASS_NAME + ":0:" >- + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:150," >- + IContextAttributes.THREAD_NAME + ":1:" >- + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:120," >- + IContextAttributes.THREAD_START_TIME + ":2:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >- + IContextAttributes.THREAD_STOP_TIME + ":3:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >- + IContextAttributes.THREAD_STATE + ":4:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >- + IContextAttributes.THREAD_RUNNING_TIME + ":5:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," >-// + IContextAttributes.THREAD_SLEEPING_TIME + ":6:" >-// + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," >- + IContextAttributes.THREAD_WAITING_TIME + ":6:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," >- + IContextAttributes.THREAD_BLOCKED_TIME + ":7:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," >- + IContextAttributes.THREAD_BLOCK_COUNT + ":8:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >- + IContextAttributes.THREAD_DEADLOCKED_TIME+ ":9:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >- + IContextAttributes.THREAD_DEADLOCK_COUNT + ":10:" >- + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80" >+ >+ public String getDefaultColumnsTemplate() { >+ return IContextAttributes.THREAD_CLASS_NAME + ":" + COL_CLASS_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:150," >+ + IContextAttributes.THREAD_NAME + ":" + COL_THREAD_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:120," >+ //+ IContextAttributes.THREAD_START_TIME + ":2:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >+ //+ IContextAttributes.THREAD_STOP_TIME + ":3:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >+ + IContextAttributes.THREAD_STATE + ":" + COL_STATE + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >+ + IContextAttributes.THREAD_RUNNING_TIME + ":" + COL_RUN_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," >+ //+ IContextAttributes.THREAD_SLEEPING_TIME + ":6:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," >+ + IContextAttributes.THREAD_WAITING_TIME + ":" + COL_WAIT_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," >+ + IContextAttributes.THREAD_BLOCKED_TIME + ":" + COL_BLOCK_TIME+ ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," >+ + IContextAttributes.THREAD_BLOCK_COUNT + ":" + COL_BLOCK_COUNT + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >+ + IContextAttributes.THREAD_DEADLOCKED_TIME + ":" + COL_DEADLOCK_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," >+ + IContextAttributes.THREAD_DEADLOCK_COUNT + ":" + COL_DEADLOCK_COUNT + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80" > ; >- } >- >- public boolean isEmptyUpdate() >- { >-// Object[] threads = PerftraceUtil.getAllThreads(_page.getMOFObject(), false); >-// for (int i = 0; i < threads.length; i++) { >-// TRCThread thread = (TRCThread)threads[i]; >-// for (Iterator it = thread.getThreadEvents().iterator(); it.hasNext(); ) { >-// Object event = it.next(); >-// if (event instanceof TRCThreadWaitingForLockEvent >-// || event instanceof TRCThreadWaitingForObjectEvent >-// || event instanceof TRCThreadSleepingEvent >-// || event instanceof TRCThreadDeadLockEvent) { >- return false; >-// } >-// } >-// } >-// return true; >- } >- >- public IContentProvider getContentProvider() >- { >+ } >+ >+ public boolean isEmptyUpdate() { >+ // Object[] threads = PerftraceUtil.getAllThreads(_page.getMOFObject(), false); >+ // for (int i = 0; i < threads.length; i++) { >+ // TRCThread thread = (TRCThread)threads[i]; >+ // for (Iterator it = thread.getThreadEvents().iterator(); it.hasNext(); >+ // ) { >+ // Object event = it.next(); >+ // if (event instanceof TRCThreadWaitingForLockEvent >+ // || event instanceof TRCThreadWaitingForObjectEvent >+ // || event instanceof TRCThreadSleepingEvent >+ // || event instanceof TRCThreadDeadLockEvent) { >+ return false; >+ // } >+ // } >+ // } >+ // return true; >+ } >+ >+ public IContentProvider getContentProvider() { > return new ThreadStatisticContentProvider(); > } >- >- public LabelProvider getTableLabelProvider() >- { >+ >+ public LabelProvider getTableLabelProvider() { > return new ThreadStatisticLabelProvider(this); > } >- >- protected StatisticSorter getViewerSorterInstance() >- { >+ >+ protected StatisticSorter getViewerSorterInstance() { > return new ThreadStatisticSorter(); > } >- >- protected StatisticFilter getFilterInstance() >- { >+ >+ protected StatisticFilter getFilterInstance() { > return new ThreadStatisticFilter(); >- } >- >- public String getColumnsPreferencesKey() >- { >- return PREFERENCE_KEY_PREFIX + "ThreadStats1"; >- } >- >- protected String getViewTypeStr() >- { >+ } >+ >+ public String getColumnsPreferencesKey() { >+ return PREFERENCE_KEY_PREFIX + "ThreadStats2"; >+ } >+ >+ protected String getViewTypeStr() { > return org.eclipse.hyades.trace.views.adapter.internal.TraceConstants.THREAD_STATS_VIEW; >- } >- >+ } >+ > public void updateButtons() { >- } >- >+ } >+ > protected void showPercentUpdate() { >- } >- >- >- public void update() >- { >- if(_page instanceof ThreadStatisticPage) >- { >+ } >+ >+ public void update() { >+ if (_page instanceof ThreadStatisticPage) { > if (_contextInfo != null) > _contextInfo.setMOFObject(_page.getMOFObject()); > } >@@ -355,15 +338,14 @@ > for (int i = 0; i < _columns.length; i++) { > _columns[i].resetMap(); > } >- >+ > super.update(); > >- if(_page instanceof ThreadStatisticPage) >- { >+ if (_page instanceof ThreadStatisticPage) { > _isEmpty = isEmptyUpdate(); > } > } >- >+ > public boolean isEmpty() { > return _isEmpty; > } >@@ -385,7 +367,7 @@ > if (width > 0) { > Region region = new Region(); > gc.getClipping(region); >- region.add(event.x, event.y, width, event.height); >+ region.add(event.x, event.y, width, event.height); > gc.setClipping(region); > region.dispose(); > } >@@ -398,16 +380,16 @@ > gc.setBackground(background); > event.detail &= ~SWT.SELECTED; > } >- } >- >+ } >+ > ThreadDetails thread = (ThreadDetails) event.item.getData(); > int state = ThreadDetails.UNKNOWN; >- if (event.index == 4) { // thread state >+ if (event.index == COL_STATE) { // thread state > state = thread.getState(); >- } else if (event.index == 8 // block count >+ } else if (event.index == COL_BLOCK_COUNT // block count > && thread.getBlockCount() > 0) { > state = ThreadDetails.BLOCKED; >- } else if (event.index == 10 // deadlock count >+ } else if (event.index == COL_DEADLOCK_COUNT // deadlock count > && thread.getDeadlockCount() > 0) { > state = ThreadDetails.DEADLOCK; > } >@@ -416,36 +398,29 @@ > GC gc = event.gc; > Color foreground = gc.getForeground(); > Color background = gc.getBackground(); >- >+ > int c1 = ThreadDetails.getStateColor(state); > int c2 = selected ? SWT.COLOR_GRAY : SWT.COLOR_WHITE; > Color sysBack = display.getSystemColor(c1); > Color sysFore = display.getSystemColor(c2); >- Color fore = mixColors(display, sysBack, sysFore, 1, 4); >- Color back = mixColors(display, sysBack, sysFore, 1, 1); >+ Color fore = Utils.mixColors(display, sysBack, sysFore, 1, 4); >+ Color back = Utils.mixColors(display, sysBack, sysFore, 1, 1); >+ >+ gc.setAdvanced(true); >+ if (gc.getAdvanced()) { >+ gc.setAlpha(180); >+ } > >- gc.setAdvanced(true); >- if (gc.getAdvanced()) { >- gc.setAlpha(180); >- } >- > gc.setBackground(back); > gc.setForeground(fore); > gc.fillGradientRectangle(event.x, event.y, event.width, event.height, false); >- >+ > gc.setForeground(foreground); > gc.setBackground(background); > back.dispose(); > fore.dispose(); > } > } >- >- private Color mixColors(Display display, Color c1, Color c2, int w1, int w2) { >- return new Color(display, >- (w1 * c1.getRed() + w2 * c2.getRed()) / (w1 + w2), >- (w1 * c1.getGreen() + w2 * c2.getGreen()) / (w1 + w2), >- (w1 * c1.getBlue() + w2 * c2.getBlue()) / (w1 + w2)); >- } > }; > tree.addListener(SWT.EraseItem, listener); > return tree; >@@ -460,62 +435,64 @@ > } > > protected void handleSelectionEvent() { >- ITraceSelection model = >- UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()); >+ ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()); > if (model.size() > 0) { > Object sel = model.getFirstElement(); > if (sel != null) { > select(sel); >- > if (sel instanceof EObject) >- updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject)sel))); >+ updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject) sel))); > } > } > } > > public void updateModelSelection() { > ISelection selection = getTreeViewer().getSelection(); >- if(selection != null && !selection.isEmpty()) >- { >- Object sel = ((IStructuredSelection)selection).getFirstElement(); >- if(sel instanceof ThreadDetails) >- notifyViewSelectionChanged(this, ((ThreadDetails)sel).getThread()); >- else >- notifyViewSelectionChanged(this,sel); >+ Object sel = null; >+ if (selection != null && !selection.isEmpty()) { >+ sel = ((IStructuredSelection) selection).getFirstElement(); >+ if (sel instanceof ThreadDetails) >+ sel = ((ThreadDetails) sel).getThread(); >+ notifyViewSelectionChanged(this, sel); >+ } >+ } >+ >+ public TRCThread getSelectedThread() { >+ TRCThread thread = null; >+ ISelection selection = getTreeViewer().getSelection(); >+ if (selection != null && !selection.isEmpty()) { >+ Object sel = ((IStructuredSelection) selection).getFirstElement(); >+ if (sel instanceof TRCThread) >+ thread = (TRCThread) sel; >+ if (sel instanceof ThreadDetails) >+ thread = ((ThreadDetails) sel).getThread(); > } >+ return thread; > } > > public void handleViewSelectionChangedEvent(ViewSelectionChangedEvent event) { >- Object source = event.getSource(); >- if(source!=this){ >+ Object source = event.getSource(); >+ if (source != this) { > handleSelectionEvent(); >- } >- else >- { >- ITraceSelection model = >- UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()); >+ } else { >+ ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()); > if (model.size() > 0) { > Object sel = model.getFirstElement(); > if (sel != null && sel instanceof EObject) >- updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject)sel))); >+ updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject) sel))); > } > } > } > > public void menuAboutToShow(IMenuManager menu) { >- > menu.add(getUpdateAction()); > menu.add(fSeparator); > resetChooseColumnsAction(); >- menu.add( >- getChooseColumnsAction( >- getColumnDataList(), >+ menu.add(getChooseColumnsAction(getColumnDataList(), > getColumnsPreferencesKey())); >- menu.add( >- getSortByColumnAction()); >- >+ menu.add(getSortByColumnAction()); > } >- >+ > public void widgetSelected(SelectionEvent e) { > super.widgetSelected(e); > if (e.widget instanceof TableColumn) { >@@ -528,7 +505,7 @@ > super.resetColumns(list); > expandFirstElement(); > } >- >+ > protected void resetChooseColumnsAction() { > _chooseColumnAction = null; > } >@@ -538,19 +515,19 @@ > return; > } > if (obj instanceof ThreadDetails) { >- obj = ((ThreadDetails)obj).getThread(); >+ obj = ((ThreadDetails) obj).getThread(); > } > Tree tree = getTree(); > TreeItem[] items = tree.getItems(); >- >+ > TreeItem item = null; > for (int j = 0; j < items.length; j++) { > item = items[j]; > >- if (item!=null && !item.isDisposed()) { >+ if (item != null && !item.isDisposed()) { > Object data = item.getData(); > if (data instanceof ThreadDetails) { >- data = ((ThreadDetails)data).getThread(); >+ data = ((ThreadDetails) data).getThread(); > } > if (data == obj) { > tree.setSelection(item); >@@ -562,31 +539,26 @@ > > protected Composite createControl(Composite parent, ArrayList cols) { > final Composite vc = super.createControl(parent, cols); >- >- if (_page.getTraceViewer() instanceof MultiLevelStatisticViewer) >- { >+ >+ if (_page.getTraceViewer() instanceof MultiLevelStatisticViewer) { > _contextInfo = new ContextInfoContainer(); >- _contextInfo.setViewer((IContextViewer)_page.getTraceViewer()); >+ _contextInfo.setViewer((IContextViewer) _page.getTraceViewer()); > _contextInfo.createControl(vc); >- _contextInfo.addContextInfoContainerListener( >- new IContextInfoContainerListener() >- { >- public void visibilityChanged(boolean isVisible) >- { >+ _contextInfo.addContextInfoContainerListener(new IContextInfoContainerListener() { >+ public void visibilityChanged(boolean isVisible) { > vc.layout(true, true); > } > }); > } >- >+ > return vc; > } >- >- protected void updateStatusContext(IContextLanguage language) >- { >+ >+ protected void updateStatusContext(IContextLanguage language) { > if (_contextInfo != null) > _contextInfo.updateStatusContext(language); > } >- >+ > protected void firstTimeUpdate() { > super.firstTimeUpdate(); > redrawTable(); >@@ -598,12 +570,19 @@ > > public void redrawTable() { > getTree().setRedraw(false); >- >- ArrayList list = ColumnData.createColumnData(getColumnsPreferencesKey(), getDefaultColumnsTemplate()); >+ ArrayList list = ColumnData.createColumnData(getColumnsPreferencesKey() >+ , getDefaultColumnsTemplate()); > resetColumns(list); > _currentColumns = list; > getTree().setRedraw(true); >- > refresh(); > } >+ >+ public void dispose() { >+ super.dispose(); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent arg0) { >+ OpenCallStackViewAction.openCallStackView(false); >+ } > } >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties,v >retrieving revision 1.2 >diff -u -r1.2 messages.properties >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties 14 Nov 2006 19:11:12 -0000 1.2 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties 13 Feb 2007 06:39:26 -0000 >@@ -13,11 +13,17 @@ > # NLS_MESSAGEFORMAT_NONE > # NLS_ENCODING=UTF-8 > >-TITLE = Thread Statistics >+THREAD_STATISTIC_TITLE = Thread Statistics >+THREAD_STATES_TITLE = Thread States >+LEGEND_LABEL = Legend >+CURRENT_TIME = Current Time >+SELECTED_TIME = Selected Time >+TIME_SCALE = Time Scale > _261 = Running > _262 = Sleeping > _263 = Waiting > _264 = Blocked > _265 = Deadlock > _266 = Stopped >+_267 = Unknown > _269 = No thread statistics is available for display.\nEither you have no trace selected in the Profiling Monitor view or the current selection does not contain thread statistics information.\n\nNote:\nThis view is available only if the trace contains thread statistics. To collect this type of information, on the Profile tab in the Launch configuration, choose the Thread Statistics option. >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenThreadStatisticViewAction.java >=================================================================== >RCS file: /cvsroot/tptp/trace/org.eclipse.tptp.trace.jvmti.client/src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenThreadStatisticViewAction.java,v >retrieving revision 1.1 >diff -u -r1.1 OpenThreadStatisticViewAction.java >--- src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenThreadStatisticViewAction.java 26 Oct 2006 19:28:23 -0000 1.1 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenThreadStatisticViewAction.java 13 Feb 2007 06:39:25 -0000 >@@ -24,7 +24,7 @@ > > public class OpenThreadStatisticViewAction extends OpenTraceViewAction { > >- private final String VIEW_ID="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatisticViewer"; >+ static final String VIEW_ID="org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatisticViewer"; > > public OpenThreadStatisticViewAction() { > super(""); >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ThreadStatesCtrl.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ThreadStatesCtrl.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ThreadStatesCtrl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ThreadStatesCtrl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,881 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.widgets; >+ >+import java.util.ArrayList; >+import java.util.Hashtable; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.hyades.models.trace.TRCThread; >+import org.eclipse.hyades.models.trace.TRCThreadEvent; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ControlEvent; >+import org.eclipse.swt.events.ControlListener; >+import org.eclipse.swt.events.FocusEvent; >+import org.eclipse.swt.events.FocusListener; >+import org.eclipse.swt.events.KeyEvent; >+import org.eclipse.swt.events.KeyListener; >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.MouseListener; >+import org.eclipse.swt.events.MouseMoveListener; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Composite; >+ >+public class ThreadStatesCtrl extends TraceCtrl implements FocusListener, >+ KeyListener, MouseMoveListener, MouseListener, ControlListener, >+ SelectionListener { >+ >+ private ITimeDataProvider _timeProvider; >+ boolean _isInFocus = false; >+ private int _topItem = 0; >+ private int _itemHeight = 18; >+ private int _dragState = 0; >+ private int _hitIdx = 0; >+ private int _dragX0 = 0; >+ private int _dragX = 0; >+ private double _timeStep = 0.01; >+ private double _time0bak; >+ private double _time1bak; >+ private ItemData _data = new ItemData(); >+ private ArrayList _selectionListeners; >+ >+ public ThreadStatesCtrl(Composite parent, TraceColorScheme colors) { >+ super(parent, colors, SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.V_SCROLL); >+ addFocusListener(this); >+ addMouseListener(this); >+ addMouseMoveListener(this); >+ addKeyListener(this); >+ addControlListener(this); >+ getVerticalBar().addSelectionListener(this); >+ getHorizontalBar().addSelectionListener(this); >+ } >+ >+ public void setTimeProvider(ITimeDataProvider timeProvider) { >+ _timeProvider = timeProvider; >+ adjustScrolls(); >+ redraw(); >+ } >+ >+ public void addSelectionListener(SelectionListener listener) { >+ if (listener == null) >+ SWT.error(SWT.ERROR_NULL_ARGUMENT); >+ if (null == _selectionListeners) >+ _selectionListeners = new ArrayList(); >+ _selectionListeners.add(listener); >+ } >+ >+ public void removeSelectionListener(SelectionListener listener) { >+ if (null != _selectionListeners) >+ _selectionListeners.remove(listener); >+ } >+ >+ public void fireSelectionChanged() { >+ if (null != _selectionListeners) { >+ Iterator it = _selectionListeners.iterator(); >+ while (it.hasNext()) { >+ SelectionListener listener = (SelectionListener) it.next(); >+ listener.widgetSelected(null); >+ } >+ } >+ } >+ >+ public void fireDefaultSelection() { >+ if (null != _selectionListeners) { >+ Iterator it = _selectionListeners.iterator(); >+ while (it.hasNext()) { >+ SelectionListener listener = (SelectionListener) it.next(); >+ listener.widgetDefaultSelected(null); >+ } >+ } >+ } >+ >+ public void refreshData(Object threads[]) { >+ _data.refreshData(threads); >+ adjustScrolls(); >+ redraw(); >+ } >+ >+ public void adjustScrolls() { >+ if (null == _timeProvider) { >+ getVerticalBar().setValues(0, 1, 1, 1, 1, 1); >+ getHorizontalBar().setValues(0, 1, 1, 1, 1, 1); >+ return; >+ } >+ int page = countPerPage(); >+ if (_topItem + page > _data._items.length) >+ _topItem = _data._items.length - page; >+ if (_topItem < 0) >+ _topItem = 0; >+ getVerticalBar().setValues(_topItem, 0, _data._items.length, page, 1, >+ page); >+ double time0 = _timeProvider.getTime0(); >+ double time1 = _timeProvider.getTime1(); >+ double timeMin = _timeProvider.getMinTime(); >+ double timeMax = _timeProvider.getMaxTime(); >+ int timePage = (int) ((time1 - time0) / _timeStep); >+ int timePos = (int) (time0 / _timeStep); >+ getHorizontalBar().setValues(timePos, (int) (timeMin / _timeStep), >+ (int) (timeMax / _timeStep), timePage, 1, timePage); >+ } >+ >+ boolean ensureVisibleItem(int idx, boolean redraw) { >+ boolean changed = false; >+ if (idx < 0 || idx >= _data._items.length) >+ return changed; >+ if (idx < _topItem) { >+ _topItem = idx; >+ getVerticalBar().setSelection(_topItem); >+ if (redraw) >+ redraw(); >+ changed = true; >+ } else { >+ int page = countPerPage(); >+ if (idx >= _topItem + page) { >+ _topItem = idx - page + 1; >+ getVerticalBar().setSelection(_topItem); >+ if (redraw) >+ redraw(); >+ changed = true; >+ } >+ } >+ return changed; >+ } >+ >+ static TRCThreadEvent getFirstEvent(TRCThread thread) { >+ EList list = thread.getThreadEvents(); >+ TRCThreadEvent event = null; >+ if (!list.isEmpty()) >+ event = (TRCThreadEvent) list.get(0); >+ return event; >+ } >+ >+ static TRCThreadEvent findEvent(TRCThread thread, double time, int n) { >+ EList list = thread.getThreadEvents(); >+ Iterator it = list.iterator(); >+ TRCThreadEvent event = null; >+ TRCThreadEvent prevEvent = null; >+ TRCThreadEvent nextEvent = null; >+ if (it.hasNext()) { >+ event = (TRCThreadEvent) it.next(); >+ double currTime = event.getTime(); >+ if (time < currTime) { >+ if (1 != n) >+ event = null; >+ return event; >+ } >+ while (it.hasNext()) { >+ nextEvent = (TRCThreadEvent) it.next(); >+ double nextTime = nextEvent.getTime(); >+ if (currTime <= time && time < nextTime) { >+ if (1 == n) >+ event = nextEvent; >+ else if (-1 == n) >+ event = prevEvent; >+ return event; >+ } >+ prevEvent = event; >+ event = nextEvent; >+ } >+ } >+ if (1 == n) >+ event = null; >+ else if (-1 == n) >+ event = prevEvent; >+ return event; >+ } >+ >+ static class Selection implements IStructuredSelection { >+ >+ List list = new ArrayList(); >+ >+ public Object getFirstElement() { >+ if (!list.isEmpty()) >+ return list.get(0); >+ return null; >+ } >+ >+ public Iterator iterator() { >+ return list.iterator(); >+ } >+ >+ public int size() { >+ return list.size(); >+ } >+ >+ public Object[] toArray() { >+ return list.toArray(); >+ } >+ >+ public List toList() { >+ return list; >+ } >+ >+ public boolean isEmpty() { >+ return list.isEmpty(); >+ } >+ } >+ >+ public ISelection getSelection() { >+ Selection sel = new Selection(); >+ TRCThread thread = getSelectedThread(); >+ if (null != thread && null != _timeProvider) { >+ double selectedTime = _timeProvider.getSelectedTime(); >+ TRCThreadEvent event = findEvent(thread, selectedTime, 0); >+ if (null != event) >+ sel.list.add(event); >+ } >+ return sel; >+ } >+ >+ public void selectEvent(int n) { >+ if (null == _timeProvider) >+ return; >+ TRCThread thread = getSelectedThread(); >+ if (thread == _timeProvider) >+ return; >+ double selectedTime = _timeProvider.getSelectedTime(); >+ double endTime = _timeProvider.getEndTime(); >+ TRCThreadEvent nextEvent; >+ if (-1 == n && selectedTime >= endTime) >+ nextEvent = findEvent(thread, selectedTime, 0); >+ else >+ nextEvent = findEvent(thread, selectedTime, n); >+ if (null != nextEvent) { >+ _timeProvider.setSelectedTime(nextEvent.getTime(), true); >+ fireSelectionChanged(); >+ } >+ else if (1 == n) { >+ _timeProvider.setSelectedTime(endTime, true); >+ fireSelectionChanged(); >+ } >+ } >+ >+ public void selectNextEvent() { >+ selectEvent(1); >+ } >+ >+ public void selectPrevEvent() { >+ selectEvent(-1); >+ } >+ >+ public TRCThread getSelectedThread() { >+ TRCThread thread = null; >+ int idx = getSelectedIndex(); >+ if (idx >= 0 && _data._items[idx] instanceof ThreadItem) >+ thread = ((ThreadItem) _data._items[idx])._thread; >+ return thread; >+ } >+ >+ public int getSelectedIndex() { >+ int idx = -1; >+ for (int i = 0; i < _data._items.length; i++) { >+ Item item = (Item) _data._items[i]; >+ if (item._selected) { >+ idx = i; >+ break; >+ } >+ } >+ return idx; >+ } >+ >+ boolean toggle(int idx) { >+ boolean toggled = false; >+ if (idx >= 0 && idx < _data._items.length) { >+ Item item = (Item) _data._items[idx]; >+ if (item._hasChildren) { >+ item._expanded = !item._expanded; >+ _data.updateItems(); >+ adjustScrolls(); >+ redraw(); >+ toggled = true; >+ } >+ } >+ return toggled; >+ } >+ >+ int hitTest(int x, int y) { >+ if (x < 0) >+ return -1; >+ if (y < 0) >+ return -1; >+ int hit = -1; >+ int idx = y / _itemHeight; >+ idx += _topItem; >+ if (idx < _data._items.length) >+ hit = idx; >+ return hit; >+ } >+ >+ double hitTimeTest(int x, int y) { >+ if (null == _timeProvider) >+ return -1; >+ double hitTime = -1; >+ Point size = getCtrlSize(); >+ double time0 = _timeProvider.getTime0(); >+ double time1 = _timeProvider.getTime1(); >+ int left = _timeProvider.getNameSpace(); >+ x -= left; >+ if (x >= 0 && size.x >= left) { >+ hitTime = time0 + (time1 - time0) * x / (size.x - left); >+ } >+ return hitTime; >+ } >+ >+ void selectItem(int idx, boolean addSelection) { >+ if (addSelection) { >+ if (idx >= 0 && idx < _data._items.length) { >+ Item item = (Item) _data._items[idx]; >+ item._selected = true; >+ } >+ } else { >+ for (int i = 0; i < _data._items.length; i++) { >+ Item item = (Item) _data._items[i]; >+ item._selected = i == idx; >+ } >+ } >+ boolean changed = ensureVisibleItem(idx, true); >+ if (!changed) >+ redraw(); >+ } >+ >+ public int countPerPage() { >+ int height = getCtrlSize().y; >+ int count = 0; >+ if (height > 0) >+ count = height / _itemHeight; >+ return count; >+ } >+ >+ public int getTopIndex() { >+ int idx = -1; >+ if (_data._items.length > 0) >+ idx = 0; >+ return idx; >+ } >+ >+ public int getBottomIndex() { >+ int idx = _data._items.length - 1; >+ return idx; >+ } >+ >+ Point getCtrlSize() { >+ Point size = getSize(); >+ size.x -= getVerticalBar().getSize().x; >+ size.y -= getHorizontalBar().getSize().y; >+ return size; >+ } >+ >+ void getNameRect(Rectangle rect, Point size, int idx, int nameWidth) { >+ idx -= _topItem; >+ rect.x = 0; >+ rect.y = idx * _itemHeight; >+ rect.width = nameWidth; >+ rect.height = _itemHeight; >+ } >+ >+ void getStatesRect(Rectangle rect, Point size, int idx, int nameWidth) { >+ idx -= _topItem; >+ rect.x = nameWidth; >+ rect.y = idx * _itemHeight; >+ rect.width = size.x - rect.x; >+ rect.height = _itemHeight; >+ } >+ >+ void paint(Rectangle rect, GC gc) { >+ Point size = getCtrlSize(); >+ if (size.x < 2 || size.y < 2 || null == _timeProvider) >+ return; >+ double time0 = _timeProvider.getTime0(); >+ double time1 = _timeProvider.getTime1(); >+ double endTime = _timeProvider.getEndTime(); >+ double selectedTime = _timeProvider.getSelectedTime(); >+ int left = _timeProvider.getNameSpace(); >+ // draw thread states >+ Object[] items = _data._items; >+ for (int i = _topItem; i < items.length; i++) { >+ Item item = (Item) items[i]; >+ getNameRect(_rect0, size, i, left); >+ if (_rect0.y >= size.y) >+ break; >+ if (item instanceof GroupItem) { >+ getStatesRect(_rect1, size, i, left); >+ _rect0.width += _rect1.width; >+ drawName(item, _rect0, gc); >+ } else { >+ drawName(item, _rect0, gc); >+ getStatesRect(_rect0, size, i, left); >+ drawItemData(item, _rect0, time0, time1, endTime, selectedTime, >+ gc); >+ } >+ } >+ // fill free canvas area >+ _rect0.x = 0; >+ _rect0.y += _rect0.height; >+ _rect0.width = size.x; >+ _rect0.height = size.y - _rect0.y; >+ if (_rect0.y < size.y) { >+ gc.setBackground(_colors.getColor(TraceColorScheme.BACKGROUND)); >+ gc.fillRectangle(_rect0); >+ } >+ } >+ >+ void drawName(Item item, Rectangle rect, GC gc) { >+ if (item instanceof GroupItem) { >+ gc.setBackground(_colors >+ .getBkColorGroup(item._selected, _isInFocus)); >+ gc.fillRectangle(rect); >+ if (item._selected && _isInFocus) { >+ gc.setForeground(_colors.getBkColor(item._selected, _isInFocus, >+ false)); >+ gc.drawRectangle(rect.x, rect.y, rect.width - 2, >+ rect.height - 2); >+ } >+ gc.setForeground(_colors.getBkColor(false, false, false)); >+ gc.drawLine(rect.x, rect.y + rect.height - 1, rect.width - 1, >+ rect.y + rect.height - 1); >+ gc.setForeground(_colors >+ .getFgColorGroup(item._selected, _isInFocus)); >+ } else { >+ gc.setBackground(_colors.getBkColor(item._selected, _isInFocus, >+ true)); >+ gc.setForeground(_colors.getFgColor(item._selected, _isInFocus)); >+ gc.fillRectangle(rect); >+ } >+ Utils.init(_rect1, rect); >+ _rect1.x += 4; >+ _rect1.width -= 4; >+ int textWidth = 0; >+ // draw text >+ if (_rect1.width > 0) >+ textWidth = Utils.drawText(gc, item._name, _rect1, true) + 8; >+ // draw middle line >+ Utils.init(_rect1, rect); >+ _rect1.x += textWidth; >+ _rect1.width -= textWidth; >+ gc.setForeground(_colors.getColor(TraceColorScheme.LIGHT_LINE)); >+ if (_rect1.width > 0 && item instanceof ThreadItem) { >+ int midy = _rect1.y + _rect1.height / 2; >+ gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy); >+ } >+ // gc.drawLine(_rect1.x + _rect1.width - 1, _rect1.y, _rect1.x + >+ // _rect1.width - 1, _rect1.y + _rect1.height); >+ } >+ >+ void drawItemData(Item item, Rectangle rect, double time0, double time1, >+ double endTime, double selectedTime, GC gc) { >+ if (rect.isEmpty()) >+ return; >+ if (time1 <= time0) { >+ gc.setBackground(_colors.getBkColor(false, false, false)); >+ gc.fillRectangle(rect); >+ return; >+ } >+ >+ Utils.init(_rect1, rect); >+ boolean selected = item._selected; >+ double K = (double) rect.width / (time1 - time0); >+ >+ if (item instanceof GroupItem) { >+ gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus)); >+ gc.fillRectangle(rect); >+ } else if (item instanceof ThreadItem) { >+ TRCThread thread = ((ThreadItem) item)._thread; >+ int x0 = rect.x; >+ EList list = thread.getThreadEvents(); >+ Iterator it = list.iterator(); >+ TRCThreadEvent lastEvent = null; >+ if (it.hasNext()) { >+ TRCThreadEvent currEvent = (TRCThreadEvent) it.next(); >+ TRCThreadEvent nextEvent = null; >+ double currEventTime = currEvent.getTime(); >+ double nextEventTime = currEventTime; >+ x0 = rect.x + (int) ((currEventTime - time0) * K); >+ int xEnd = rect.x + (int) ((time1 - time0) * K); >+ int x1 = -1; >+ >+ // reduce rect >+ _rect1.y += 3; >+ _rect1.height -= 6; >+ >+ // fill space before first event >+ if (x0 > rect.x) { >+ _rect1.width = (x0 <= xEnd ? x0 : xEnd) - _rect1.x; >+ gc.setBackground(_colors.getBkColor(selected, _isInFocus, >+ false)); >+ gc.fillRectangle(_rect1); >+ // draw middle line >+ gc.setForeground(_colors >+ .getColor(TraceColorScheme.MID_LINE)); >+ int midy = _rect1.y + _rect1.height / 2; >+ gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy); >+ } >+ >+ // draw event states >+ while (x0 <= xEnd && null != currEvent) { >+ boolean stopped = false;//currEvent instanceof TRCThreadDeadEvent; >+ if (it.hasNext()) { >+ nextEvent = (TRCThreadEvent) it.next(); >+ nextEventTime = nextEvent.getTime(); >+ } else if (stopped) { >+ nextEvent = null; >+ nextEventTime = time1; >+ } else { >+ nextEvent = null; >+ nextEventTime = endTime; >+ } >+ x1 = rect.x + (int) ((nextEventTime - time0) * K); >+ if (x1 >= rect.x) { >+ _rect1.x = x0 >= rect.x ? x0 : rect.x; >+ _rect1.width = (x1 <= xEnd ? x1 : xEnd) - _rect1.x; >+ boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime; >+ Utils.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected); >+ } >+ lastEvent = currEvent; >+ currEvent = nextEvent; >+ currEventTime = nextEventTime; >+ x0 = x1; >+ } >+ } >+ >+ // fill space after last event >+ int xEnd = rect.x + rect.width; >+ if (x0 < xEnd) { >+ _rect1.x = x0 >= rect.x ? x0 : rect.x; >+ _rect1.width = xEnd - _rect1.x; >+ gc.setBackground(_colors.getBkColor(selected, _isInFocus, false)); >+ gc.fillRectangle(_rect1); >+ // draw middle line >+ gc.setForeground(_colors.getColor(Utils.getEventColor(lastEvent))); >+ int midy = _rect1.y + _rect1.height / 2; >+ int lw = gc.getLineWidth(); >+ gc.setLineWidth(2); >+ gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy); >+ gc.setLineWidth(lw); >+ } >+ >+ // draw focus ares >+ Utils.init(_rect1, rect); >+ gc.setForeground(_colors.getBkColor(false, false, false)); >+ int y = _rect1.y; >+ gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y); >+ y++; >+ gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y); >+ y++; >+ gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y); >+ y = _rect1.y + _rect1.height - 1; >+ gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y); >+ y--; >+ gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y); >+ y--; >+ gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y); >+ // gc.setForeground(_colors.getBkColor(selected, _isInFocus, >+ // false)); >+ } >+ >+ // draw selected time >+ int x = rect.x + (int) ((selectedTime - time0) * K); >+ if (x >= rect.x && x < rect.x + rect.width) { >+ gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME)); >+ gc.drawLine(x, rect.y, x, rect.y + rect.height); >+ } >+ } >+ >+ public void keyPressed(KeyEvent e) { >+ int idx = -1; >+ if (SWT.HOME == e.keyCode) { >+ idx = getTopIndex(); >+ } else if (SWT.END == e.keyCode) { >+ idx = getBottomIndex(); >+ } else if (SWT.ARROW_DOWN == e.keyCode) { >+ idx = getSelectedIndex(); >+ if (idx < 0) >+ idx = 0; >+ else if (idx < _data._items.length - 1) >+ idx++; >+ } else if (SWT.ARROW_UP == e.keyCode) { >+ idx = getSelectedIndex(); >+ if (idx < 0) >+ idx = 0; >+ else if (idx > 0) >+ idx--; >+ } else if (SWT.ARROW_LEFT == e.keyCode) { >+ selectPrevEvent(); >+ } else if (SWT.ARROW_RIGHT == e.keyCode) { >+ selectNextEvent(); >+ } else if (SWT.PAGE_DOWN == e.keyCode) { >+ int page = countPerPage(); >+ idx = getSelectedIndex(); >+ if (idx < 0) >+ idx = 0; >+ idx += page; >+ if (idx >= _data._items.length) >+ idx = _data._items.length - 1; >+ } else if (SWT.PAGE_UP == e.keyCode) { >+ int page = countPerPage(); >+ idx = getSelectedIndex(); >+ if (idx < 0) >+ idx = 0; >+ idx -= page; >+ if (idx < 0) >+ idx = 0; >+ } else if (SWT.CR == e.keyCode) { >+ idx = getSelectedIndex(); >+ if (idx >= 0) { >+ if (_data._items[idx] instanceof ThreadItem) >+ fireDefaultSelection(); >+ else if (_data._items[idx] instanceof GroupItem) >+ toggle(idx); >+ } >+ idx = -1; >+ } >+ if (idx >= 0) { >+ selectItem(idx, false); >+ fireSelectionChanged(); >+ } >+ } >+ >+ public void keyReleased(KeyEvent e) { >+ } >+ >+ public void focusGained(FocusEvent e) { >+ _isInFocus = true; >+ redraw(); >+ } >+ >+ public void focusLost(FocusEvent e) { >+ _isInFocus = false; >+ if (1 == _dragState) { >+ setCapture(false); >+ _dragState = 0; >+ } >+ redraw(); >+ } >+ >+ public void mouseMove(MouseEvent e) { >+ Point size = getCtrlSize(); >+ if (1 == _dragState && null != _timeProvider) { >+ int leftSpace = _timeProvider.getNameSpace(); >+ int x = e.x - leftSpace; >+ if (x > 0 && size.x > leftSpace && _dragX != x) { >+ _dragX = x; >+ double K = (double) (size.x - leftSpace) >+ / (_time1bak - _time0bak); >+ double timeDelta = (_dragX - _dragX0) / K; >+ double time1 = _time1bak - timeDelta; >+ double maxTime = _timeProvider.getMaxTime(); >+ if (time1 > maxTime) >+ time1 = maxTime; >+ double time0 = time1 - (_time1bak - _time0bak); >+ if (time0 < 0) >+ time0 = 0; >+ _timeProvider.setStartFinishTime(time0, time1); >+ } >+ } >+ } >+ >+ public void mouseDoubleClick(MouseEvent e) { >+ if (1 == e.button) { >+ int idx = hitTest(e.x, e.y); >+ if (idx >= 0) { >+ selectItem(idx, false); >+ if (_data._items[idx] instanceof ThreadItem) { >+ fireDefaultSelection(); >+ } >+ } >+ } >+ } >+ >+ public void mouseDown(MouseEvent e) { >+ if (null == _timeProvider) >+ return; >+ if (1 == e.button) { >+ int idx = hitTest(e.x, e.y); >+ if (idx >= 0) { >+ if (_data._items[idx] instanceof ThreadItem) { >+ double hitTime = hitTimeTest(e.x, e.y); >+ if (hitTime >= 0) { >+ _timeProvider.setSelectedTime(hitTime, false); >+ setCapture(true); >+ _dragState = 1; >+ _dragX = _dragX0 = e.x - _timeProvider.getNameSpace(); >+ _time0bak = _timeProvider.getTime0(); >+ _time1bak = _timeProvider.getTime1(); >+ } >+ } else if (_data._items[idx] instanceof GroupItem) { >+ _hitIdx = idx; >+ _dragState = 2; >+ } >+ selectItem(idx, false); >+ fireSelectionChanged(); >+ } >+ } >+ } >+ >+ public void mouseUp(MouseEvent e) { >+ if (0 != _dragState) { >+ setCapture(false); >+ if (2 == _dragState) { >+ if (hitTest(e.x, e.y) == _hitIdx) >+ toggle(_hitIdx); >+ } >+ _dragState = 0; >+ } >+ } >+ >+ public void controlMoved(ControlEvent e) { >+ } >+ >+ public void controlResized(ControlEvent e) { >+ adjustScrolls(); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ if (e.widget == getVerticalBar()) { >+ _topItem = getVerticalBar().getSelection(); >+ if (_topItem < 0) >+ _topItem = 0; >+ redraw(); >+ } else if (e.widget == getHorizontalBar() && null != _timeProvider) { >+ int startTime = getHorizontalBar().getSelection(); >+ double time0 = _timeProvider.getTime0(); >+ double time1 = _timeProvider.getTime1(); >+ double range = time1 - time0; >+ // _timeRangeFixed = true; >+ time0 = _timeStep * startTime; >+ time1 = time0 + range; >+ _timeProvider.setStartFinishTime(time0, time1); >+ } >+ } >+} >+ >+class Item { >+ public boolean _expanded; >+ public boolean _selected; >+ public boolean _hasChildren; >+ public String _name; >+ >+ Item(String name) { >+ _name = name; >+ } >+ >+ public String toString() { >+ return _name; >+ } >+} >+ >+class ThreadItem extends Item { >+ public TRCThread _thread; >+ >+ ThreadItem(TRCThread thread) { >+ super(thread.getName()); >+ _thread = thread; >+ } >+} >+ >+class GroupItem extends Item { >+ public ArrayList _threads; >+ >+ GroupItem(String name) { >+ super(name); >+ _threads = new ArrayList(); >+ _hasChildren = true; >+ } >+ >+ void add(Object thread) { >+ _threads.add(thread); >+ } >+} >+ >+class ItemData { >+ public Object[] _items = new Object[0]; >+ private Object _threads[] = new Object[0]; >+ private Hashtable _groupTable = new Hashtable(); >+ private boolean _flatList; >+ >+ void clearGroups() { >+ Set keys = _groupTable.keySet(); >+ Iterator it = keys.iterator(); >+ while (it.hasNext()) { >+ String key = (String) it.next(); >+ GroupItem group = (GroupItem) _groupTable.get(key); >+ group._threads.clear(); >+ } >+ } >+ >+ void deleteEmptyGroups() { >+ Set keys = _groupTable.keySet(); >+ Iterator it = keys.iterator(); >+ while (it.hasNext()) { >+ String key = (String) it.next(); >+ GroupItem group = (GroupItem) _groupTable.get(key); >+ if (group._threads.size() == 0) >+ _groupTable.remove(key); >+ } >+ } >+ >+ public void updateItems() { >+ ArrayList itemList = new ArrayList(); >+ Set keys = _groupTable.keySet(); >+ Iterator it = keys.iterator(); >+ while (it.hasNext()) { >+ String key = (String) it.next(); >+ GroupItem group = (GroupItem) _groupTable.get(key); >+ if (!_flatList) >+ itemList.add(group); >+ if (_flatList || group._expanded) { >+ Iterator it2 = group._threads.iterator(); >+ while (it2.hasNext()) >+ itemList.add(new ThreadItem((TRCThread) it2.next())); >+ } >+ } >+ _items = itemList.toArray(); >+ } >+ >+ public void refreshData(Object threads[]) { >+ clearGroups(); >+ _threads = threads; >+ String undef = "<undefined>"; >+ ArrayList groupList = new ArrayList(); >+ for (int i = 0; i < _threads.length; i++) { >+ TRCThread thread = (TRCThread) _threads[i]; >+ String groupName = thread.getGroupName(); >+ if (null == groupName) >+ groupName = undef; >+ GroupItem group = (GroupItem) _groupTable.get(groupName); >+ if (null == group) { >+ group = new GroupItem(groupName); >+ group._expanded = !groupName.equalsIgnoreCase("system") >+ && !groupName.equalsIgnoreCase(undef); >+ _groupTable.put(groupName, group); >+ groupList.add(group); >+ } >+ group.add(thread); >+ } >+ deleteEmptyGroups(); >+ updateItems(); >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenCallStackViewAction.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenCallStackViewAction.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenCallStackViewAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenCallStackViewAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.core.resources.IResourceStatus; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.hyades.trace.ui.UIPlugin; >+import org.eclipse.hyades.trace.views.actions.internal.OpenTraceViewAction; >+import org.eclipse.hyades.trace.views.internal.TraceUIMessages; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.ui.IWorkbenchWindow; >+ >+public class OpenCallStackViewAction extends OpenTraceViewAction { >+ >+ static final String VIEW_ID = "org.eclipse.tptp.trace.jvmti.internal.client.views.CallStackView"; >+ >+ public OpenCallStackViewAction() { >+ super(""); >+ } >+ >+ public OpenCallStackViewAction(String label) { >+ super(label); >+ } >+ >+ public OpenCallStackViewAction(String label, ImageDescriptor image) { >+ super(label, image); >+ } >+ >+ public boolean isVisibleForType(Object mofObject) { >+ return true; >+ } >+ >+ static public void openCallStackView(boolean showError) { >+ IWorkbenchWindow window = UIPlugin.getDefault().getWorkbench() >+ .getActiveWorkbenchWindow(); >+ try { >+ UIPlugin.getActivePage().showView(VIEW_ID); >+ } catch (Exception e) { >+ if (showError) { >+ String msg = TraceUIMessages._3; >+ Status err = new Status(Status.WARNING, >+ ResourcesPlugin.PI_RESOURCES, >+ IResourceStatus.INTERNAL_ERROR, e.toString(), null); >+ ErrorDialog.openError(window.getShell(), msg, "", err); >+ } >+ e.printStackTrace(); >+ } >+ } >+ >+ public void run() { >+ openCallStackView(true); >+ } >+ >+ public void run(IAction action) { >+ run(); >+ } >+ >+ public String getViewID() { >+ return VIEW_ID; >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TraceCtrl.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TraceCtrl.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TraceCtrl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TraceCtrl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.widgets; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.PaintEvent; >+import org.eclipse.swt.events.PaintListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Canvas; >+import org.eclipse.swt.widgets.Composite; >+ >+public abstract class TraceCtrl extends Canvas implements PaintListener { >+ >+ protected TraceColorScheme _colors; >+ protected Rectangle _rect0 = new Rectangle(0, 0, 0, 0); >+ protected Rectangle _rect1 = new Rectangle(0, 0, 0, 0); >+ >+ public TraceCtrl(Composite parent, TraceColorScheme colors) { >+ this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS); >+ } >+ >+ public TraceCtrl(Composite parent, TraceColorScheme colors, int style) { >+ super(parent, style); >+ _colors = colors; >+ addPaintListener(this); >+ } >+ >+ public void dispose() { >+ super.dispose(); >+ } >+ >+ public void paintControl(PaintEvent e) { >+ if (e.widget != this) >+ return; >+ Point size = getSize(); >+ if (size.x > 0 && size.y > 0) { >+ Color colBackup = e.gc.getBackground(); >+ Utils.init(_rect0, 0, 0, size.x, size.y); >+ paint(_rect0, e.gc); >+ e.gc.setBackground(colBackup); >+ } >+ } >+ >+ void paint(Rectangle rect, GC gc) { >+ gc.setBackground(_colors.getColor(TraceColorScheme.BACKGROUND)); >+ gc.fillRectangle(rect); >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/Utils.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/Utils.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/Utils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/Utils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,168 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.widgets; >+ >+import org.eclipse.hyades.models.trace.TRCThreadDeadEvent; >+import org.eclipse.hyades.models.trace.TRCThreadDeadLockEvent; >+import org.eclipse.hyades.models.trace.TRCThreadEvent; >+import org.eclipse.hyades.models.trace.TRCThreadRunningEvent; >+import org.eclipse.hyades.models.trace.TRCThreadSleepingEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForLockEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForObjectEvent; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Device; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Display; >+ >+public class Utils { >+ >+ static public void init(Rectangle rect) { >+ rect.x = 0; >+ rect.y = 0; >+ rect.width = 0; >+ rect.height = 0; >+ } >+ >+ static public void init(Rectangle rect, int x, int y, int width, int height) { >+ rect.x = x; >+ rect.y = y; >+ rect.width = width; >+ rect.height = height; >+ } >+ >+ static public void init(Rectangle rect, Rectangle source) { >+ rect.x = source.x; >+ rect.y = source.y; >+ rect.width = source.width; >+ rect.height = source.height; >+ } >+ >+ static public void deflate(Rectangle rect, int x, int y) { >+ rect.x += x; >+ rect.y += y; >+ rect.width -= x + x; >+ rect.height -= y + y; >+ } >+ >+ static public void inflate(Rectangle rect, int x, int y) { >+ rect.x -= x; >+ rect.y -= y; >+ rect.width += x + x; >+ rect.height += y + y; >+ } >+ >+ static void dispose(Color col) { >+ if (null != col) >+ col.dispose(); >+ } >+ >+ static public Color mixColors(Device display, Color c1, Color c2, int w1, >+ int w2) { >+ return new Color(display, (w1 * c1.getRed() + w2 * c2.getRed()) >+ / (w1 + w2), (w1 * c1.getGreen() + w2 * c2.getGreen()) >+ / (w1 + w2), (w1 * c1.getBlue() + w2 * c2.getBlue()) >+ / (w1 + w2)); >+ } >+ >+ static public Color getSysColor(int id) { >+ return Display.getCurrent().getSystemColor(id); >+ } >+ >+ static public Color mixColors(Color col1, Color col2, int w1, int w2) { >+ return mixColors(Display.getCurrent(), col1, col2, w1, w2); >+ } >+ >+ static public void drawState(TraceColorScheme colors, TRCThreadEvent event, >+ Rectangle rect, GC gc, boolean selected, boolean rectBound, boolean timeSelected) { >+ int colorIdx = getEventColor(event); >+ drawState(colors, colorIdx, rect, gc, selected, rectBound, timeSelected); >+ } >+ >+ static public void drawState(TraceColorScheme colors, int colorIdx, >+ Rectangle rect, GC gc, boolean selected, boolean rectBound, boolean timeSelected) { >+ if (rect.isEmpty()) >+ return; >+ // FILL RECT >+ int colorIdx1 = colorIdx; >+ timeSelected = timeSelected && selected; >+ if (selected) >+ colorIdx1 = colorIdx + TraceColorScheme.STATES_SEL0 - TraceColorScheme.STATES0; >+ gc.setBackground(colors.getColor(colorIdx1)); >+ gc.fillRectangle(rect); >+ colorIdx1 = colorIdx + TraceColorScheme.STATES_BORDER0 - TraceColorScheme.STATES0; >+ gc.setForeground(colors.getColor(colorIdx1)); >+ // DRAW BOUNDS >+ if (!timeSelected) { >+ if (rectBound && rect.width >= 3) { >+ gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1); >+ } else { >+ gc.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y); >+ gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); >+ } >+ } >+ // DRAW MID LINE >+ int mindy = rect.y + rect.height / 2; >+ if (TraceColorScheme.BLOCKED == colorIdx || TraceColorScheme.WAITING == colorIdx) { >+ int s = gc.getLineStyle(); >+ int w = gc.getLineWidth(); >+ gc.setLineStyle(SWT.LINE_DOT); >+ gc.setLineWidth(2); >+ gc.drawLine(rect.x, mindy, rect.x + rect.width, mindy); >+ gc.setLineStyle(s); >+ gc.setLineWidth(w); >+ } else if (TraceColorScheme.DEADLOCK == colorIdx || TraceColorScheme.STOPPED == colorIdx) { >+ int w = gc.getLineWidth(); >+ gc.setLineWidth(2); >+ gc.drawLine(rect.x, mindy, rect.x + rect.width, mindy); >+ gc.setLineWidth(w); >+ } >+ // DRAW SELECTED BOUNDS >+ if (timeSelected) { >+ if (rect.width >= 3) { >+ gc.setForeground(colors.getColor(TraceColorScheme.SELECTED_TIME)); >+ gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1); >+ //gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3, rect.height - 3); >+ } else { >+ gc.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y); >+ gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); >+ } >+ } >+ } >+ >+ static public int getEventColor(TRCThreadEvent event) { >+ if (event instanceof TRCThreadRunningEvent) >+ return TraceColorScheme.RUNNING; >+ else if (event instanceof TRCThreadSleepingEvent) >+ return TraceColorScheme.SLEEPING; >+ else if (event instanceof TRCThreadDeadLockEvent) >+ return TraceColorScheme.DEADLOCK; >+ else if (event instanceof TRCThreadWaitingForLockEvent) >+ return TraceColorScheme.BLOCKED; >+ else if (event instanceof TRCThreadWaitingForObjectEvent) >+ return TraceColorScheme.WAITING; >+ else if (event instanceof TRCThreadDeadEvent) >+ return TraceColorScheme.STOPPED; >+ return TraceColorScheme.UNKNOWN; >+ } >+ >+ static public int drawText(GC gc, String text, Rectangle rect, boolean transp) { >+ Point size = gc.stringExtent(text); >+ gc.drawText(text, rect.x, rect.y, transp); >+ return size.x; >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenThreadStatesViewAction.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenThreadStatesViewAction.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenThreadStatesViewAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/OpenThreadStatesViewAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,78 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.core.resources.IResourceStatus; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.hyades.trace.ui.TraceViewer; >+import org.eclipse.hyades.trace.ui.UIPlugin; >+import org.eclipse.hyades.trace.views.actions.internal.OpenTraceViewAction; >+import org.eclipse.hyades.trace.views.internal.TraceUIMessages; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+ >+public class OpenThreadStatesViewAction extends OpenTraceViewAction { >+ >+ private final String VIEW_ID = "org.eclipse.tptp.trace.jvmti.internal.client.views.ThreadStatesViewer"; >+ >+ public OpenThreadStatesViewAction() { >+ super(""); >+ } >+ >+ public OpenThreadStatesViewAction(String label) { >+ super(label); >+ } >+ >+ public OpenThreadStatesViewAction(String label, ImageDescriptor image) { >+ super(label, image); >+ } >+ >+ public boolean isVisibleForType(Object mofObject) { >+ return true; >+ } >+ >+ public void run() { >+ IWorkbenchWindow window = UIPlugin.getDefault().getWorkbench() >+ .getActiveWorkbenchWindow(); >+ try { >+ IWorkbenchPage persp = UIPlugin.getActivePage(); >+ IViewPart view = persp.showView(VIEW_ID); >+ if (view != null && view instanceof TraceViewer) { >+ ((TraceViewer) view).addViewPage(getMofObject(), true); >+ } >+ } catch (Exception e) { >+ String msg = TraceUIMessages._3; >+ Status err = new Status(Status.WARNING, >+ ResourcesPlugin.PI_RESOURCES, >+ IResourceStatus.INTERNAL_ERROR, e.toString(), null); >+ ErrorDialog.openError(window.getShell(), msg, "", err); >+ e.printStackTrace(); >+ } >+ >+ } >+ >+ public void run(IAction action) { >+ run(); >+ } >+ >+ public String getViewID() { >+ return VIEW_ID; >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesViewer.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesViewer.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesViewer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesViewer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,91 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.hyades.trace.ui.TraceViewer; >+import org.eclipse.hyades.trace.ui.TraceViewerPage; >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.IToolBarManager; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.PlatformUI; >+ >+public class ThreadStatesViewer extends TraceViewer { >+ >+ public ThreadStatesViewer() { >+ } >+ >+ public TraceViewerPage createPage(EObject mofObject) { >+ return new ThreadStatesPage(mofObject, this); >+ } >+ >+ public String getViewTitle() { >+ return UIMessages.THREAD_STATES_TITLE; >+ } >+ >+ public void setFocus() { >+ if (getCurrentPage() != null) >+ getCurrentPage().setFocus(); >+ } >+ >+ public void makeActions() { >+ super.makeActions(); >+ createActions(); >+ IActionBars bars = getViewSite().getActionBars(); >+ fillLocalPullDown(bars.getMenuManager()); >+ fillLocalToolBar(bars.getToolBarManager()); >+ bars.updateActionBars(); >+ } >+ >+ Action _selectNextEvent; >+ Action _selectPrevEvent; >+ >+ private void createActions() { >+ _selectNextEvent = new Action() { >+ public void run() { >+ if (getCurrentPage() instanceof ThreadStatesPage) >+ ((ThreadStatesPage) getCurrentPage()).selectNextEvent(); >+ } >+ }; >+ _selectNextEvent.setText("Next"); >+ _selectNextEvent.setToolTipText("Select Next Event"); >+ _selectNextEvent.setImageDescriptor(PlatformUI.getWorkbench() >+ .getSharedImages().getImageDescriptor( >+ ISharedImages.IMG_TOOL_FORWARD)); >+ _selectPrevEvent = new Action() { >+ public void run() { >+ if (getCurrentPage() instanceof ThreadStatesPage) >+ ((ThreadStatesPage) getCurrentPage()).selectPrevEvent(); >+ } >+ }; >+ _selectPrevEvent.setText("Prev"); >+ _selectPrevEvent.setToolTipText("Select Previous Event"); >+ _selectPrevEvent.setImageDescriptor(PlatformUI.getWorkbench() >+ .getSharedImages().getImageDescriptor( >+ ISharedImages.IMG_TOOL_BACK)); >+ } >+ >+ private void fillLocalPullDown(IMenuManager manager) { >+ manager.add(_selectPrevEvent); >+ manager.add(_selectNextEvent); >+ } >+ >+ private void fillLocalToolBar(IToolBarManager manager) { >+ manager.add(_selectPrevEvent); >+ manager.add(_selectNextEvent); >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesPage.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesPage.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatesPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,319 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.hyades.models.trace.TRCThread; >+import org.eclipse.hyades.models.trace.TRCThreadEvent; >+import org.eclipse.hyades.trace.ui.TraceViewer; >+import org.eclipse.hyades.trace.ui.TraceViewerPage; >+import org.eclipse.hyades.trace.ui.UIPlugin; >+import org.eclipse.hyades.trace.ui.ViewSelectionChangedEvent; >+import org.eclipse.hyades.trace.ui.internal.util.PerftraceUtil; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ControlAdapter; >+import org.eclipse.swt.events.ControlEvent; >+import org.eclipse.swt.events.PaintEvent; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.ITimeDataProvider; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.LegendCtrl; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.ThreadStatesCtrl; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.TimeScaleCtrl; >+import org.eclipse.tptp.trace.jvmti.internal.client.widgets.TraceColorScheme; >+ >+public class ThreadStatesPage extends TraceViewerPage implements >+ ITimeDataProvider, SelectionListener { >+ >+ /* vars */ >+ double _minTimeInterval = .000001; >+ double _selectedTime = -1; >+ double _beginTime = 0; >+ double _endTime = 0; >+ double _time0 = 0; >+ double _time1 = 0; >+ double _time0_ = 0; >+ double _time1_ = 0; >+ double _time1bak = 0; >+ double _timeStep = 0.01; >+ boolean _timeRangeFixed = false; >+ private int _nameWidth = 96; >+ private int _legendHeight = 22; >+ private int _timeScaleHeight = 22; >+ private Composite _viewContainer; >+ private ThreadStatesCtrl _stateCtrl; >+ private LegendCtrl _legendCtrl; >+ private TimeScaleCtrl _timeScaleCtrl; >+ static TraceColorScheme _colors = new TraceColorScheme(); >+ >+ /** ctor */ >+ public ThreadStatesPage(EObject mofObject, TraceViewer viewer) { >+ super(mofObject, viewer); >+ } >+ >+ /** Refresher */ >+ public void refreshPage() { >+ if (null != _stateCtrl) { >+ refreshData(); >+ _stateCtrl.redraw(); >+ _timeScaleCtrl.redraw(); >+ } >+ } >+ >+ public void selectionChanged() { >+ } >+ >+ public void update(boolean newPage) { >+ refreshPage(); >+ } >+ >+ public void createControl(Composite parent) { >+ _viewContainer = new Composite(parent, SWT.NULL); >+ _legendCtrl = new LegendCtrl(_viewContainer, _colors); >+ _timeScaleCtrl = new TimeScaleCtrl(_viewContainer, _colors); >+ _timeScaleCtrl.setTimeProvider(this); >+ _stateCtrl = new ThreadStatesCtrl(_viewContainer, _colors); >+ _stateCtrl.setTimeProvider(this); >+ _stateCtrl.addSelectionListener(this); >+ _viewContainer.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent event) { >+ Rectangle r = _viewContainer.getClientArea(); >+ _legendCtrl.setBounds(r.x, r.y, r.width, _legendHeight); >+ _timeScaleCtrl.setBounds(r.x, r.y + _legendHeight, r.width, >+ _timeScaleHeight); >+ _stateCtrl.setBounds(r.x, r.y + _legendHeight >+ + _timeScaleHeight, r.width, r.height - _legendHeight >+ - _timeScaleHeight); >+ } >+ }); >+ } >+ >+ public void dispose() { >+ _stateCtrl.dispose(); >+ _legendCtrl.dispose(); >+ _viewContainer.dispose(); >+ _colors.dispose(); >+ super.dispose(); >+ } >+ >+ /** Tries to set most convinient time range for display. */ >+ void setTimeRange(Object threads[]) { >+ _endTime = 0; >+ _beginTime = -1; >+ TRCThreadEvent event; >+ for (int i = 0; i < threads.length; i++) { >+ TRCThread thread = (TRCThread) threads[i]; >+ double lastEventTime = thread.getStopTime(); >+ if (lastEventTime > thread.getStartTime()) { >+ if (lastEventTime > _endTime) >+ _endTime = lastEventTime; >+ } >+ EList list = thread.getThreadEvents(); >+ int len = list.size(); >+ if (len > 0) { >+ event = (TRCThreadEvent) list.get(list.size() - 1); >+ lastEventTime = event.getTime(); >+ if (lastEventTime > _endTime) >+ _endTime = lastEventTime; >+ event = (TRCThreadEvent) list.get(0); >+ if (_beginTime < 0 || _beginTime > event.getTime()) >+ _beginTime = event.getTime(); >+ } >+ } >+ _endTime += 0.1; >+ if (_beginTime < 0) >+ _beginTime = 0; >+ } >+ >+ void setTimeBounds() { >+ _time0_ = _beginTime - (_endTime - _beginTime) * 0.05; >+ if (_time0_ < 0) >+ _time0_ = 0; >+ _time1_ = _time0_ + (_endTime - _time0_) * 1.05; >+ _time0_ = Math.floor(_time0_); >+ _time1_ = Math.ceil(_time1_); >+ if (!_timeRangeFixed) { >+ _time0 = _time0_; >+ _time1 = _time1_; >+ } >+ } >+ >+ void refreshData() { >+ Object threads[] = PerftraceUtil.getAllThreads(getMOFObject(), false); >+ if (null == threads) >+ threads = new TRCThread[0]; >+ setTimeRange(threads); >+ setTimeBounds(); >+ if (_selectedTime < 0 || _selectedTime > _endTime) >+ _selectedTime = _endTime; >+ _stateCtrl.refreshData(threads); >+ } >+ >+ public Control getControl() { >+ return _viewContainer; >+ } >+ >+ public void setFocus() { >+ if (null != _stateCtrl) >+ _stateCtrl.setFocus(); >+ } >+ >+ public TRCThread getSelectedThread() { >+ return _stateCtrl.getSelectedThread(); >+ } >+ >+ public ISelection getSelection() { >+ return _stateCtrl.getSelection(); >+ } >+ >+ public double getTime0() { >+ return _time0; >+ } >+ >+ public double getTime1() { >+ return _time1; >+ } >+ >+ public double getMinTimeInterval() { >+ return _minTimeInterval; >+ } >+ >+ public int getNameSpace() { >+ return _nameWidth; >+ } >+ >+ public int getTimeSpace() { >+ int w = _stateCtrl.getClientArea().width; >+ return w - _nameWidth; >+ } >+ >+ public double getSelectedTime() { >+ return _selectedTime; >+ } >+ >+ public double getBeginTime() { >+ return _beginTime; >+ } >+ >+ public double getEndTime() { >+ return _endTime; >+ } >+ >+ public double getMaxTime() { >+ return _time1_; >+ } >+ >+ public double getMinTime() { >+ return _time0_; >+ } >+ >+ public void setStartFinishTime(double time0, double time1) { >+ _time0 = time0; >+ if (_time0 < 0) >+ _time0 = 0; >+ _time1 = time1; >+ if (_time1 - _time0 < _minTimeInterval) >+ _time1 = _time0 + _minTimeInterval; >+ if (_time1 > _time1_) >+ _time1 = _time1_; >+ _timeRangeFixed = true; >+ _stateCtrl.adjustScrolls(); >+ _stateCtrl.redraw(); >+ _timeScaleCtrl.redraw(); >+ } >+ >+ public void resetStartFinishTime() { >+ _timeRangeFixed = false; >+ _time0 = _time0_; >+ _time1 = _time1_; >+ _stateCtrl.adjustScrolls(); >+ _stateCtrl.redraw(); >+ _timeScaleCtrl.redraw(); >+ } >+ >+ public void paintControl(PaintEvent e) { >+ } >+ >+ public void setSelectedTime(double time, boolean ensureVisible) { >+ _selectedTime = time; >+ if (_selectedTime > _endTime) >+ _selectedTime = _endTime; >+ if (_selectedTime < _beginTime) >+ _selectedTime = _beginTime; >+ if (ensureVisible) { >+ double timeSpace = (_time1 - _time0) * .1; >+ double timeMid = (_time1 - _time0) * .5; >+ if (_selectedTime < _time0 + timeSpace) { >+ double dt = _time0 - _selectedTime + timeMid; >+ _time0 -= dt; >+ _time1 -= dt; >+ } else if (_selectedTime > _time1 - timeSpace) { >+ double dt = _selectedTime - _time1 + timeMid; >+ _time0 += dt; >+ _time1 += dt; >+ } >+ if (_time0 < 0) { >+ _time1 -= _time0; >+ _time0 = 0; >+ } else if (_time1 > _time1_) { >+ _time0 += _time1 - _time1_; >+ _time1 = _time1_; >+ } >+ } >+ _stateCtrl.adjustScrolls(); >+ _stateCtrl.redraw(); >+ _timeScaleCtrl.redraw(); >+ } >+ >+ public void updateModelSelection() { >+ ISelection selection = getSelection(); >+ Object sel = null; >+ if (selection != null && !selection.isEmpty()) { >+ sel = ((IStructuredSelection) selection).getFirstElement(); >+ notifyViewSelectionChanged(this, sel); >+ } >+ } >+ >+ public void notifyViewSelectionChanged(Object source, Object selection) { >+ UIPlugin.getDefault().getSelectionModel(getMOFObject()).add(selection); >+ ViewSelectionChangedEvent event = UIPlugin.getDefault() >+ .getViewSelectionChangedEvent(); >+ event.setSource(source); >+ UIPlugin.getDefault().notifyViewSelectionChangedListener(event); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ OpenCallStackViewAction.openCallStackView(false); >+ updateModelSelection(); >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ updateModelSelection(); >+ } >+ >+ public void selectNextEvent() { >+ _stateCtrl.selectNextEvent(); >+ } >+ >+ public void selectPrevEvent() { >+ _stateCtrl.selectPrevEvent(); >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ITimeDataProvider.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ITimeDataProvider.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ITimeDataProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ITimeDataProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.widgets; >+ >+public interface ITimeDataProvider { >+ >+ double getSelectedTime(); >+ >+ double getBeginTime(); >+ >+ double getEndTime(); >+ >+ double getMinTime(); >+ >+ double getMaxTime(); >+ >+ double getTime0(); >+ >+ double getTime1(); >+ >+ double getMinTimeInterval(); >+ >+ void setStartFinishTime(double time0, double time1); >+ >+ void setSelectedTime(double time, boolean ensureVisible); >+ >+ void resetStartFinishTime(); >+ >+ int getNameSpace(); >+ >+ int getTimeSpace(); >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/views/CallStackViewer.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/views/CallStackViewer.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/views/CallStackViewer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/views/CallStackViewer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,280 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.views; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.hyades.models.trace.TRCMethod; >+import org.eclipse.hyades.models.trace.TRCMethodInvocation; >+import org.eclipse.hyades.models.trace.TRCThread; >+import org.eclipse.hyades.models.trace.TRCThreadDeadEvent; >+import org.eclipse.hyades.models.trace.TRCThreadDeadLockEvent; >+import org.eclipse.hyades.models.trace.TRCThreadEvent; >+import org.eclipse.hyades.models.trace.TRCThreadRunningEvent; >+import org.eclipse.hyades.models.trace.TRCThreadSleepingEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForLockEvent; >+import org.eclipse.hyades.models.trace.TRCThreadWaitingForObjectEvent; >+import org.eclipse.hyades.trace.ui.IViewSelectionChangedListener; >+import org.eclipse.hyades.trace.ui.UIPlugin; >+import org.eclipse.hyades.trace.ui.ViewSelectionChangedEvent; >+import org.eclipse.hyades.trace.views.util.internal.OpenSource; >+import org.eclipse.jface.viewers.DoubleClickEvent; >+import org.eclipse.jface.viewers.IDoubleClickListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.TreeSelection; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.ISharedImages; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.part.ViewPart; >+ >+public class CallStackViewer extends ViewPart implements >+ IViewSelectionChangedListener { >+ >+ private TreeViewer _calStackCtrl; >+ private Object _selection; >+ >+ public CallStackViewer() { >+ } >+ >+ public void createPartControl(Composite parent) { >+ _calStackCtrl = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL >+ | SWT.FULL_SELECTION | SWT.SINGLE); >+ _calStackCtrl.setContentProvider(new CallStackContentProvider()); >+ _calStackCtrl.setLabelProvider(new CallStackLabelProvider()); >+ _calStackCtrl.setInput(this); >+ _calStackCtrl.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ OpenSource.openSource(getFirstSelectedElement()); >+ } >+ }); >+ UIPlugin.getDefault().addViewSelectionChangedListener(this); >+ UIPlugin.getDefault().getViewSelectionChangedEvent(); >+ } >+ >+ public void setFocus() { >+ if (null != _calStackCtrl) >+ _calStackCtrl.getControl().setFocus(); >+ } >+ >+ public void dispose() { >+ UIPlugin.getDefault().removeViewSelectionChangedListener(this); >+ super.dispose(); >+ } >+ >+ public Object getFirstSelectedElement() { >+ Object obj = null; >+ if (null != _calStackCtrl) >+ obj = ((TreeSelection) _calStackCtrl.getSelection()) >+ .getFirstElement(); >+ return obj; >+ } >+ >+ /** update view content */ >+ void update(Object selection) { >+ if (null == _calStackCtrl) >+ return; >+ _selection = selection; >+ _calStackCtrl.refresh(); >+ } >+ >+ public void handleObjectChanged(Object sel) { >+ update(sel); >+ } >+ >+ /** >+ * Compose String name for TRCMethodInvocation >+ * >+ * @param method >+ * @return >+ */ >+ static String methodName(TRCMethodInvocation method) { >+ TRCMethod m = method.getMethod(); >+ String name = ""; >+ name += m.getDefiningClass().getName(); >+ name += "."; >+ name += m.getName(); >+ name += m.getSignature(); >+ name += " [" + m.getCalls() + "]"; >+ return name; >+ } >+ >+ /** >+ * Compose String name for TRCThread >+ * >+ * @param thread >+ * @return >+ */ >+ static String threadName(TRCThread thread) { >+ String name = thread.getName(); >+ name += " [" + thread.getGroupName() + "]"; >+ return name; >+ } >+ >+ static String getEventName(TRCThreadEvent event) { >+ if (event instanceof TRCThreadRunningEvent) { >+ return "RUNNING"; >+ } else if (event instanceof TRCThreadSleepingEvent) { >+ return "SLEEPING"; >+ } else if (event instanceof TRCThreadDeadLockEvent) { >+ return "DEADLOCK"; >+ } else if (event instanceof TRCThreadWaitingForLockEvent) { >+ return "BLOCKED"; >+ } else if (event instanceof TRCThreadWaitingForObjectEvent) { >+ return "WAITING"; >+ } else if (event instanceof TRCThreadDeadEvent) { >+ return "STOPPED"; >+ } >+ return "UNKNOWN"; >+ } >+ >+ /** >+ * Compose String name for TRCThreadEvent >+ * >+ * @param event >+ * @return >+ */ >+ static String eventName(TRCThreadEvent event) { >+ String name = event.getThread().getName(); >+ name += " [" + event.getThread().getGroupName() + "] State: " + getEventName(event); >+ if (event instanceof TRCThreadWaitingForObjectEvent) { >+ name += " Timeout=" + ((TRCThreadWaitingForObjectEvent)event).getTimeout(); >+ } else if (event instanceof TRCThreadWaitingForLockEvent) { >+ TRCThread thread = ((TRCThreadWaitingForLockEvent)event).getLockingThread(); >+ if (null != thread) >+ name += " by Thread=" + thread.getName(); >+ } >+ return name; >+ } >+ >+ /** >+ * Compose String name from object >+ * >+ * @param obj >+ * @return >+ */ >+ public String getItemText(Object obj) { >+ if (obj instanceof TRCMethodInvocation) { >+ return methodName((TRCMethodInvocation) obj); >+ } >+ if (obj instanceof TRCThread) { >+ return threadName((TRCThread) obj); >+ } >+ if (obj instanceof TRCThreadEvent) { >+ return eventName((TRCThreadEvent) obj); >+ } >+ return obj.toString(); >+ } >+ >+ /** >+ * Icon image for object. >+ * >+ * @param obj >+ * @return >+ */ >+ public Image getItemImage(Object obj) { >+ Image img = null; >+ String imageKey = ISharedImages.IMG_OBJ_ELEMENT; >+ if (obj instanceof TRCMethodInvocation) { >+ imageKey = ISharedImages.IMG_OBJ_FILE; >+ } >+ if (null == img) { >+ img = PlatformUI.getWorkbench().getSharedImages() >+ .getImage(imageKey); >+ } >+ return img; >+ } >+ >+ static final Object[] empty = new Object[0]; >+ >+ class CallStackContentProvider implements ITreeContentProvider { >+ >+ public void inputChanged(Viewer v, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object parent) { >+ Object[] ret = empty; >+ if (null != _selection) >+ ret = new Object[] { _selection }; >+ return ret; >+ } >+ >+ public Object[] getChildren(Object parentElement) { >+ Object[] ret = empty; >+ if (parentElement instanceof TRCThread) { >+ TRCThread thread = (TRCThread) parentElement; >+ TRCMethodInvocation mi; >+ ArrayList arrlist = new ArrayList(); >+ EList list = thread.getInitialInvocations(); >+ while (list != null && !list.isEmpty()) { >+ mi = (TRCMethodInvocation) list.get(list.size() - 1); >+ arrlist.add(mi); >+ list = mi.getInvokes(); >+ } >+ ret = arrlist.toArray(); >+ } else if (parentElement instanceof TRCThreadEvent) { >+ // TODO: CS from event >+ ret = new String[] { "Placeholder for EVENT's call stack...", }; >+ } >+ return ret; >+ } >+ >+ public Object getParent(Object element) { >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ boolean ret = false; >+ if (element instanceof TRCThread) { >+ ret = true; >+ } else if (element instanceof TRCThreadEvent) { >+ ret = true; >+ } >+ return ret; >+ } >+ } >+ >+ class CallStackLabelProvider extends LabelProvider { >+ public String getText(Object obj) { >+ return getItemText(obj); >+ } >+ >+ public Image getImage(Object obj) { >+ return getItemImage(obj); >+ } >+ } >+ >+ public void handleViewSelectionChangedEvent(ViewSelectionChangedEvent event) { >+ Object source = event.getSource(); >+ if (source instanceof ThreadStatisticView) { >+ ThreadStatisticView view = (ThreadStatisticView) source; >+ TRCThread thread = view.getSelectedThread(); >+ update(thread); >+ } else if (source instanceof ThreadStatesPage) { >+ ThreadStatesPage page = (ThreadStatesPage) source; >+ IStructuredSelection sel = (IStructuredSelection) page.getSelection(); >+ update(sel.getFirstElement()); >+ } >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TimeScaleCtrl.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TimeScaleCtrl.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TimeScaleCtrl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TimeScaleCtrl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,303 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.widgets; >+ >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.MouseListener; >+import org.eclipse.swt.events.MouseMoveListener; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.tptp.trace.jvmti.internal.client.views.UIMessages; >+ >+public class TimeScaleCtrl extends TraceCtrl implements MouseListener, MouseMoveListener { >+ >+ public TimeScaleCtrl(Composite parent, TraceColorScheme colors) { >+ super(parent, colors); >+ addMouseListener(this); >+ addMouseMoveListener(this); >+ } >+ >+ private ITimeDataProvider _timeProvider; >+ private int _dragState = 0; >+ private int _dragX0 = 0; >+ private int _dragX = 0; >+ private double _time0bak; >+ private double _time1bak; >+ private boolean _isInUpdate; >+ >+ public void setTimeProvider(ITimeDataProvider timeProvider) { >+ _timeProvider = timeProvider; >+ } >+ >+ private double _timeDeltaD; >+ private long _timeDelta; >+ private void calcTimeDelta(int width, double K) { >+ long D[] = { 1, 2, 5, }; >+ long pow = 1; >+ double powD = 0.000000001; >+ long td = pow; >+ double tdD = powD; >+ double dx = tdD * K; >+ int i = 0; >+ while (dx < width) { >+ td = D[i] * pow; >+ tdD = D[i] * powD; >+ dx = tdD * K; >+ i++; >+ if (i == 3) { >+ i = 0; >+ pow *= 10; >+ powD *= 10; >+ } >+ } >+ _timeDeltaD = tdD; >+ _timeDelta = td; >+ } >+ >+ static private TimeDraw _tds[] = new TimeDraw[] { >+ new TimeDrawSec(), >+ new TimeDrawMillisec(), >+ new TimeDrawMicrosec(), >+ new TimeDrawNanosec(), >+ }; >+ >+ static TimeDraw getTimeDraw(long timeDelta) { >+ TimeDraw timeDraw; >+ if (timeDelta >= 1000000000) >+ timeDraw = _tds[0]; >+ else if (timeDelta >= 1000000) >+ timeDraw = _tds[1]; >+ else if (timeDelta >= 1000) >+ timeDraw = _tds[2]; >+ else >+ timeDraw = _tds[3]; >+ return timeDraw; >+ } >+ >+ void paint(Rectangle rect, GC gc) { >+ >+ if (_isInUpdate || null == _timeProvider) >+ return; >+ >+ if (null == _timeProvider) { >+ gc.fillRectangle(rect); >+ return; >+ } >+ >+ gc.setBackground(_colors.getColor(TraceColorScheme.TOOL_BACKGROUND)); >+ gc.setForeground(_colors.getColor(TraceColorScheme.TOOL_FOREGROUND)); >+ double time0 = _timeProvider.getTime0(); >+ double time1 = _timeProvider.getTime1(); >+ double selectedTime = _timeProvider.getSelectedTime(); >+ int leftSpace = _timeProvider.getNameSpace(); >+ int timeSpace = _timeProvider.getTimeSpace(); >+ >+ if (time1 <= time0) { >+ gc.fillRectangle(rect); >+ return; >+ } >+ double timeRange = time1 - time0; >+ int numDigits = 8; // 11:222 >+ if (timeRange < .00001) >+ numDigits = 16; // 11:222:333:444__ >+ else if (timeRange < .01) >+ numDigits = 12; // 11:222:333__ >+ >+ Utils.init(_rect1, rect); >+ int labelWidth = gc.getCharWidth('0') * numDigits; >+ double K = 1; >+ if (rect.width - leftSpace > 0) { >+ K = (double) timeSpace / (time1 - time0); >+ calcTimeDelta(labelWidth, K); >+ } >+ TimeDraw timeDraw = getTimeDraw(_timeDelta); >+ >+ // draw top left area >+ _rect1.width = leftSpace; >+ gc.fillRectangle(_rect1); >+ _rect1.x += 4; >+ _rect1.width -= 4; >+ if (_rect1.width > 0) { >+ if (rect.width - leftSpace > 0) >+ Utils.drawText(gc, "Time: " + timeDraw.hint(), _rect1, true); >+ else >+ Utils.drawText(gc, UIMessages.TIME_SCALE, _rect1, true); >+ } >+ _rect1.x -= 4; >+ _rect1.width += 4; >+ >+ // prepare and draw right rect of the timescale >+ _rect1.x += leftSpace; >+ _rect1.width = rect.width - leftSpace; >+ >+ // draw bottom border and erase all other area >+ gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, >+ rect.y + rect.height - 1); >+ _rect1.height--; >+ gc.fillRectangle(_rect1); >+ >+ if (_rect1.isEmpty()) >+ return; >+ >+ // draw selected time >+ int x = _rect1.x + (int) ((selectedTime - time0) * K); >+ if (x >= _rect1.x && x < _rect1.x + _rect1.width) { >+ gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME)); >+ gc.drawLine(x, _rect1.y + _rect1.height - 6, x, _rect1.y + _rect1.height); >+ gc.setForeground(_colors.getColor(TraceColorScheme.TOOL_FOREGROUND)); >+ } >+ >+ // draw time scale ticks >+ _rect1.y = rect.y; >+ _rect1.height = rect.height - 4; >+ _rect1.width = labelWidth; >+ double time = Math.floor(time0 / _timeDeltaD) * _timeDeltaD; >+ long t = (long)(time * 1000000000); >+ int y = _rect1.y + _rect1.height; >+ while (true) { >+ x = rect.x + leftSpace + (int) ((time - time0) * K); >+ if (x >= rect.x + leftSpace + rect.width - _rect1.width) { >+ break; >+ } >+ if (x >= rect.x + leftSpace) { >+ gc.drawLine(x, y, x, y + 4); >+ _rect1.x = x; >+ if (x + _rect1.width <= rect.x + rect.width) >+ timeDraw.draw(gc, t, _rect1); >+ } >+ time += _timeDeltaD; >+ t += _timeDelta; >+ } >+ } >+ >+ public void mouseDown(MouseEvent e) { >+ if (1 == e.button && null != _timeProvider) { >+ setCapture(true); >+ _dragState = 1; >+ _dragX = _dragX0 = e.x - _timeProvider.getNameSpace(); >+ _time0bak = _timeProvider.getTime0(); >+ _time1bak = _timeProvider.getTime1(); >+ } >+ } >+ >+ public void mouseUp(MouseEvent e) { >+ if (1 == _dragState) { >+ setCapture(false); >+ _dragState = 0; >+ } >+ } >+ >+ public void mouseMove(MouseEvent e) { >+ Point size = getSize(); >+ if (1 == _dragState && null != _timeProvider) { >+ int leftSpace = _timeProvider.getNameSpace(); >+ int x = e.x - leftSpace; >+ if (x > 0 && size.x > leftSpace && _dragX != x) { >+ _dragX = x; >+ double time1 = _time0bak + (_time1bak - _time0bak) * _dragX0 / _dragX; >+ _timeProvider.setStartFinishTime(_time0bak, time1); >+ } >+ } >+ } >+ >+ public void mouseDoubleClick(MouseEvent e) { >+ if (null != _timeProvider) { >+ _timeProvider.resetStartFinishTime(); >+ } >+ } >+} >+ >+abstract class TimeDraw { >+ static String S = ":"; >+ static String S0 = ":0"; >+ static String S00 = ":00"; >+ >+ static String pad(long n) { >+ String s = S; >+ if (n < 10) >+ s = S00; >+ else if (n < 100) >+ s = S0; >+ return s + n; >+ } >+ >+ public abstract void draw(GC gc, long time, Rectangle rect); >+ public abstract String hint(); >+} >+ >+class TimeDrawSec extends TimeDraw { >+ static String _hint = "sec"; >+ >+ public void draw(GC gc, long time, Rectangle rect) { >+ time /= 1000000000; >+ Utils.drawText(gc, time + "", rect, true); >+ } >+ >+ public String hint() { >+ return _hint; >+ } >+} >+ >+class TimeDrawMillisec extends TimeDraw { >+ static String _hint = "s:ms"; >+ >+ public void draw(GC gc, long time, Rectangle rect) { >+ time /= 1000000; >+ long ms = time % 1000; >+ time /= 1000; >+ Utils.drawText(gc, time + pad(ms), rect, true); >+ } >+ >+ public String hint() { >+ return _hint; >+ } >+} >+ >+class TimeDrawMicrosec extends TimeDraw { >+ static String _hint = "s:ms:mcs"; >+ >+ public void draw(GC gc, long time, Rectangle rect) { >+ time /= 1000; >+ long mcs = time % 1000; >+ time /= 1000; >+ long ms = time % 1000; >+ time /= 1000; >+ Utils.drawText(gc, time + pad(ms) + pad(mcs), rect, true); >+ } >+ >+ public String hint() { >+ return _hint; >+ } >+} >+ >+class TimeDrawNanosec extends TimeDraw { >+ static String _hint = "s:ms:mcs:ns"; >+ >+ public void draw(GC gc, long time, Rectangle rect) { >+ long ns = time % 1000; >+ time /= 1000; >+ long mcs = time % 1000; >+ time /= 1000; >+ long ms = time % 1000; >+ time /= 1000; >+ Utils.drawText(gc, time + pad(ms) + pad(mcs) + pad(ns), rect, true); >+ } >+ >+ public String hint() { >+ return _hint; >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/LegendCtrl.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/LegendCtrl.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/LegendCtrl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/LegendCtrl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.widgets; >+ >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.tptp.trace.jvmti.internal.client.views.UIMessages; >+ >+public class LegendCtrl extends TraceCtrl { >+ >+ static private String _names[]; >+ >+ public LegendCtrl(Composite parent, TraceColorScheme colors) { >+ super(parent, colors); >+ } >+ >+ static private String [] getNames() { >+ if (null == _names) { >+ String names[] = { >+ UIMessages._267, // "Unknown", >+ UIMessages._261, // "Running", >+ UIMessages._262, // "Sleeping", >+ UIMessages._263, // "Waiting", >+ UIMessages._264, // "Blocked", >+ UIMessages._265, // "Deadlock", >+ UIMessages._266, // "Stopped", >+ }; >+ _names = names; >+ } >+ return _names; >+ } >+ >+ void paint(Rectangle rect, GC gc) { >+ gc.setBackground(_colors.getColor(TraceColorScheme.LEGEND_BACKGROUND)); >+ gc.fillRectangle(rect); >+ // draw legend rect >+ Utils.init(_rect1, rect); >+ //gc.setForeground(_colors.getColor(TraceColorScheme.LEGEND_FOREGROUND)); >+ //gc.drawRectangle(_rect1.x, _rect1.y, _rect1.width - 1, _rect1.height - 1); >+ // draw legend elements >+ int idx = 0; >+ String names[] = getNames(); >+ _rect1.x += 4; >+ _rect1.y += 2; >+ while (idx < names.length && _rect1.x < rect.x + rect.width) { >+ Point size = gc.stringExtent(names[idx]); >+ _rect1.width = 16; >+ _rect1.height = size.y; >+ Utils.drawState(_colors, idx, _rect1, gc, false, true, false); >+ _rect1.x += _rect1.width + 2; >+ _rect1.width = size.x; >+ gc.setForeground(_colors.getColor(TraceColorScheme.LEGEND_FOREGROUND)); >+ Utils.drawText(gc, names[idx], _rect1, true); >+ _rect1.x += _rect1.width + 8; >+ idx++; >+ } >+ } >+} >Index: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TraceColorScheme.java >=================================================================== >RCS file: src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TraceColorScheme.java >diff -N src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TraceColorScheme.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/TraceColorScheme.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,281 @@ >+/***************************************************************************** >+ * Copyright (c) 1997-2006, Intel Corporation. >+ * 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: >+ * Intel Corporation - Initial API and implementation >+ * Ruslan A. Scherbakov, Intel - Initial API and implementation >+ * >+ * $Id$ >+ *****************************************************************************/ >+ >+package org.eclipse.tptp.trace.jvmti.internal.client.widgets; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Color; >+ >+public class TraceColorScheme { >+ >+ // state elements color indices >+ static public final int UNKNOWN = 0; >+ static public final int RUNNING = 1; >+ static public final int SLEEPING = 2; >+ static public final int WAITING = 3; >+ static public final int BLOCKED = 4; >+ static public final int DEADLOCK = 5; >+ static public final int STOPPED = 6; >+ >+ static public final int STATES0 = 0; >+ static public final int STATES1 = 7; >+ >+ // selected state elements color indices >+ static public final int UNKNOWN_SEL = 7; >+ static public final int RUNNING_SEL = 8; >+ static public final int SLEEPING_SEL = 9; >+ static public final int WAITING_SEL = 10; >+ static public final int BLOCKED_SEL = 11; >+ static public final int DEADLOCK_SEL = 12; >+ static public final int STOPPED_SEL = 13; >+ >+ static public final int STATES_SEL0 = 7; >+ static public final int STATES_SEL1 = 13; >+ >+ // colors indices for viewer controls >+ static public final int BACKGROUND = 14; >+ static public final int FOREGROUND = 15; >+ static public final int BACKGROUND_SEL = 16; >+ static public final int FOREGROUND_SEL = 17; >+ static public final int BACKGROUND_SEL_NOFOCUS = 18; >+ static public final int FOREGROUND_SEL_NOFOCUS = 19; >+ static public final int TOOL_BACKGROUND = 20; >+ static public final int TOOL_FOREGROUND = 21; >+ >+ // misc colors >+ static public final int FIX_COLOR = 22; >+ static public final int WHITE = 23; >+ static public final int GRAY = 24; >+ static public final int BLACK = 25; >+ static public final int DARK_GRAY = 26; >+ >+ // selected state elements border color indices >+ static public final int UNKNOWN_BORDER = 27; >+ static public final int RUNNING_BORDER = 28; >+ static public final int SLEEPING_BORDER = 29; >+ static public final int WAITING_BORDER = 30; >+ static public final int BLOCKED_BORDER = 31; >+ static public final int DEADLOCK_BORDER = 32; >+ static public final int STOPPED_BORDER = 33; >+ >+ static public final int STATES_BORDER0 = 27; >+ static public final int STATES_BORDER1 = 33; >+ >+ static public final int MID_LINE = 34; >+ static public final int RED = 35; >+ static public final int GREEN = 36; >+ static public final int BLUE = 37; >+ static public final int YELLOW = 38; >+ static public final int CYAN = 39; >+ static public final int MAGENTA = 40; >+ >+ static public final int SELECTED_TIME = 41; >+ static public final int LEGEND_BACKGROUND = 42; >+ static public final int LEGEND_FOREGROUND = 43; >+ >+ // group items' colors >+ static public final int GR_BACKGROUND = 44; >+ static public final int GR_FOREGROUND = 45; >+ static public final int GR_BACKGROUND_SEL = 46; >+ static public final int GR_FOREGROUND_SEL = 47; >+ static public final int GR_BACKGROUND_SEL_NOFOCUS = 48; >+ static public final int GR_FOREGROUND_SEL_NOFOCUS = 49; >+ >+ static public final int LIGHT_LINE = 50; >+ static public final int BACKGROUND_NAME = 51; >+ >+ static interface IColorProvider { >+ public Color get(); >+ } >+ >+ static class SysCol implements IColorProvider { >+ int syscol; >+ >+ SysCol(int syscol) { >+ this.syscol = syscol; >+ } >+ >+ public Color get() { >+ return Utils.getSysColor(syscol); >+ } >+ } >+ >+ static class RGB implements IColorProvider { >+ int r; >+ int g; >+ int b; >+ >+ RGB(int r, int g, int b) { >+ this.r = r; >+ this.g = g; >+ this.b = b; >+ } >+ >+ public Color get() { >+ return new Color(null, r, g, b); >+ } >+ } >+ >+ static class Mix implements IColorProvider { >+ IColorProvider cp1; >+ IColorProvider cp2; >+ int w1; >+ int w2; >+ >+ Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) { >+ this.cp1 = cp1; >+ this.cp2 = cp2; >+ this.w1 = w1; >+ this.w2 = w2; >+ } >+ >+ Mix(IColorProvider cp1, IColorProvider cp2) { >+ this.cp1 = cp1; >+ this.cp2 = cp2; >+ this.w1 = 1; >+ this.w2 = 1; >+ } >+ >+ public Color get() { >+ Color col1 = cp1.get(); >+ Color col2 = cp2.get(); >+ Color col = Utils.mixColors(col1, col2, w1, w2); >+ return col; >+ } >+ } >+ >+ static private final IColorProvider _providersMap[] = { >+ // >+ new RGB(100, 100, 100), // UNKNOWN >+ new RGB(174, 200, 124), // RUNNING >+ new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING >+ new RGB(210, 150, 60), // WAITING >+ new RGB(242, 225, 168), // BLOCKED >+ new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK >+ new RGB(200, 200, 200), // STOPPED >+ >+ new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL >+ new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL >+ new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL >+ new SysCol(SWT.COLOR_CYAN), // WAITING_SEL >+ new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL >+ new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL >+ new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL >+ >+ new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND >+ new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND >+ new SysCol(SWT.COLOR_LIST_SELECTION), // BACKGROUND_SEL >+ new SysCol(SWT.COLOR_LIST_SELECTION_TEXT), // FOREGROUND_SEL >+ new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS >+ new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS >+ new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND >+ new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND >+ >+ new SysCol(SWT.COLOR_GRAY), // FIX_COLOR >+ new SysCol(SWT.COLOR_WHITE), // WHITE >+ new SysCol(SWT.COLOR_GRAY), // GRAY >+ new SysCol(SWT.COLOR_BLACK), // BLACK >+ new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY >+ >+ new SysCol(SWT.COLOR_DARK_GRAY), // UNKNOWN_BORDER >+ new RGB(75, 115, 120), // RUNNING_BORDER >+ new SysCol(SWT.COLOR_DARK_BLUE), // SLEEPING_BORDER >+ new RGB(242, 225, 168), // WAITING_BORDER >+ new RGB(210, 150, 60), // BLOCKED_BORDER >+ new SysCol(SWT.COLOR_DARK_RED), // DEADLOCK_BORDER >+ new SysCol(SWT.COLOR_BLACK), // STOPPED_BORDER >+ >+ new SysCol(SWT.COLOR_GRAY), // MID_LINE >+ new SysCol(SWT.COLOR_RED), // RED >+ new SysCol(SWT.COLOR_GREEN), // GREEN >+ new SysCol(SWT.COLOR_BLUE), // BLUE >+ new SysCol(SWT.COLOR_YELLOW), // YELLOW >+ new SysCol(SWT.COLOR_CYAN), // CYAN >+ new SysCol(SWT.COLOR_MAGENTA), // MAGENTA >+ >+ new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME >+ new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND >+ new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND >+ >+ new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_LIST_BACKGROUND)),// GR_BACKGROUND >+ new RGB(0, 0, 50), // GR_FOREGROUND >+ new Mix(new RGB(200, 200, 100), new SysCol(SWT.COLOR_LIST_SELECTION)), // GR_BACKGROUND_SEL >+ new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_LIST_SELECTION_TEXT)), // GR_FOREGROUND_SEL >+ new Mix(new RGB(222, 222, 155), new SysCol(SWT.COLOR_WIDGET_BACKGROUND)), // GR_BACKGROUND_SEL_NOFOCUS >+ new RGB(0, 0, 50), // GR_FOREGROUND_SEL_NOFOCUS >+ >+ new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE >+ new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6), // BACKGROUND_NAME >+ }; >+ >+ private Color _colors[]; >+ >+ public TraceColorScheme() { >+ _colors = new Color[_providersMap.length]; >+ } >+ >+ public void dispose() { >+ for (int i = 0; i < _colors.length; i++) { >+ Utils.dispose(_colors[i]); >+ _colors[i] = null; >+ } >+ } >+ >+ public Color getColor(int idx) { >+ if (null == _colors[idx]) { >+ if (idx >= STATES_SEL0 && idx <= STATES_SEL1) { >+ Color col1 = getColor(idx - STATES_SEL0); >+ Color col2 = getColor(BACKGROUND_SEL); >+ _colors[idx] = Utils.mixColors(col1, col2, 3, 1); >+ } else { >+ _colors[idx] = _providersMap[idx].get(); >+ } >+ } >+ return _colors[idx]; >+ } >+ >+ public Color getBkColor(boolean selected, boolean focused, boolean name) { >+ if (selected && focused) >+ return getColor(BACKGROUND_SEL); >+ if (selected) >+ return getColor(BACKGROUND_SEL_NOFOCUS); >+ if (name) >+ return getColor(BACKGROUND_NAME); >+ return getColor(BACKGROUND); >+ } >+ >+ public Color getFgColor(boolean selected, boolean focused) { >+ if (selected && focused) >+ return getColor(FOREGROUND_SEL); >+ if (selected) >+ return getColor(FOREGROUND_SEL_NOFOCUS); >+ return getColor(FOREGROUND); >+ } >+ >+ public Color getBkColorGroup(boolean selected, boolean focused) { >+ if (selected && focused) >+ return getColor(GR_BACKGROUND_SEL); >+ if (selected) >+ return getColor(GR_BACKGROUND_SEL_NOFOCUS); >+ return getColor(GR_BACKGROUND); >+ } >+ >+ public Color getFgColorGroup(boolean selected, boolean focused) { >+ if (selected && focused) >+ return getColor(GR_FOREGROUND_SEL); >+ if (selected) >+ return getColor(GR_FOREGROUND_SEL_NOFOCUS); >+ return getColor(GR_FOREGROUND); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 167609
:
57785
|
57787
|
58675
|
58754
|
58831
|
58964
|
58965
|
58966
|
59900
|
59901
|
60096