From 480ee167c86d33bfd89a887b10c027949772c4fe Mon Sep 17 00:00:00 2001 From: Patrick Chuong Date: Tue, 15 Feb 2011 21:12:12 +0000 Subject: [PATCH] Bug 334566 - [multicore][Pin&Clone] Add support for icon overlay in the debug view --- .../icons/obj16/debugt_obj_b.gif | Bin 0 -> 261 bytes .../icons/obj16/debugt_obj_g.gif | Bin 0 -> 261 bytes .../icons/obj16/debugt_obj_r.gif | Bin 0 -> 261 bytes .../icons/obj16/debugts_obj_b.gif | Bin 0 -> 596 bytes .../icons/obj16/debugts_obj_g.gif | Bin 0 -> 596 bytes .../icons/obj16/debugts_obj_r.gif | Bin 0 -> 596 bytes .../icons/obj16/thread_obj_b.gif | Bin 0 -> 360 bytes .../icons/obj16/thread_obj_g.gif | Bin 0 -> 360 bytes .../icons/obj16/thread_obj_r.gif | Bin 0 -> 360 bytes .../icons/obj16/threads_obj_b.gif | Bin 0 -> 579 bytes .../icons/obj16/threads_obj_g.gif | Bin 0 -> 579 bytes .../icons/obj16/threads_obj_r.gif | Bin 0 -> 579 bytes .../icons/obj16/toolbar_pinned.gif | Bin 0 -> 359 bytes .../icons/obj16/toolbar_pinned_b.gif | Bin 0 -> 359 bytes .../icons/obj16/toolbar_pinned_g.gif | Bin .../icons/obj16/toolbar_pinned_multi.gif | Bin 0 -> 357 bytes .../icons/obj16/toolbar_pinned_r.gif | Bin 0 -> 359 bytes .../org/eclipse/cdt/ui/CDTSharedImages.java | 24 ++ .../META-INF/MANIFEST.MF | 1 + .../icons/elcl16/toolbar_pinned.gif | Bin 0 -> 359 bytes debug/org.eclipse.cdt.debug.ui/plugin.xml | 6 +- .../PinDebugContextActionDelegate.java | 101 +++++-- .../ui/pinclone/DebugContextPinProvider.java | 18 +- .../internal/ui/pinclone/PinCloneUtils.java | 94 ++++++- .../eclipse/cdt/debug/ui/IPinProvider.java | 67 ++++- .../cdt/debug/ui/PinElementHandle.java | 34 ++- .../gdb/internal/ui/GdbAdapterFactory.java | 4 +- .../gdb/internal/ui/GdbPinColorTracker.java | 83 ++++++ .../dsf/gdb/internal/ui/GdbPinProvider.java | 258 ++++++++++++++---- .../ui/viewmodel/launch/ContainerVMNode.java | 114 +++++++- .../launch/IGdbLaunchVMConstants.java | 10 + .../ui/viewmodel/launch/ThreadVMNode.java | 108 +++++++- dsf/org.eclipse.cdt.dsf.ui/icons/pin.gif | Bin 358 -> 0 bytes .../icons/toolbar_pinned.gif | Bin 0 -> 359 bytes dsf/org.eclipse.cdt.dsf.ui/plugin.xml | 2 +- .../launch/AbstractContainerVMNode.java | 7 + .../launch/AbstractThreadVMNode.java | 9 +- .../viewmodel/launch/StateChangedEvent.java | 26 ++ .../icons/pin.gif | Bin 358 -> 0 bytes .../icons/toolbar_pinned.gif | Bin 0 -> 359 bytes .../plugin.xml | 2 +- 41 files changed, 858 insertions(+), 110 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_b.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_g.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_r.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/debugts_obj_b.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/debugts_obj_g.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/debugts_obj_r.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/thread_obj_b.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/thread_obj_g.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/thread_obj_r.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/threads_obj_b.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/threads_obj_g.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/threads_obj_r.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_b.gif rename debug/org.eclipse.cdt.debug.ui/icons/elcl16/pin.gif => core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_g.gif (100%) create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_multi.gif create mode 100644 core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_r.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/elcl16/toolbar_pinned.gif create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinColorTracker.java delete mode 100644 dsf/org.eclipse.cdt.dsf.ui/icons/pin.gif create mode 100644 dsf/org.eclipse.cdt.dsf.ui/icons/toolbar_pinned.gif create mode 100644 dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/launch/StateChangedEvent.java delete mode 100644 memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/icons/pin.gif create mode 100644 memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/icons/toolbar_pinned.gif diff --git a/core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_b.gif b/core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_b.gif new file mode 100644 index 0000000000000000000000000000000000000000..fa6cbffc8e12cb8a293d18d95607b7356801dc89 GIT binary patch literal 261 zcmZ?wbhEHb6krfwXpv=LP*i77*JIE#W3aJfvx#7^$>X*0tzU?p69DNCnGGSZP~2e;{EgOdzN0hKi~e)mL+R;pZmYx{_wfG|L@2D|3Cl# z?+^cBK=CIFBLjmxgAM}_fb3*oZF-{(;XPTJB>iKTx@B~loP;9@mF5NKfo!3Ocm4Vm9 zMQyzeL&74A4UOXylT*31f^x$0mH4J9msNNxiSY2wuxhlE6yy@&((F`b6%?PaUQ?05 F8UQ;;UK#)Z literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_g.gif b/core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_g.gif new file mode 100644 index 0000000000000000000000000000000000000000..0ac4ae3d220e043439e65ac30fcce33162c76482 GIT binary patch literal 261 zcmZ?wbhEHb6krfwXpv(OH;QGj$zyP<4Y4p_2vTS8>tXQgWeAgF01fX5@BVVVby3S#m6MVq}i#=$R|Ew Jy{00AH2~-mV?F=? literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_r.gif b/core/org.eclipse.cdt.ui/icons/obj16/debugt_obj_r.gif new file mode 100644 index 0000000000000000000000000000000000000000..7e2e45c86bd8aebfbf53592699ec8a5762aa4cc9 GIT binary patch literal 261 zcmZ?wbhEHb6krfwXpv(OH;QGj$=fa=z~EN9T~;{6!eG0SID=mggI_O0==AM6Qrq=Z zw;SqjH&xnhCZFf4y4~7rPDWTt+p<}`#rx;m_bk11f4=>pElbwyKKFmW{o!+W|KE@Q z|9}4f-yi;if#OdVMg|6X1|0?<0NKgF+VnuZ?i5pR#xF^~;<`Y=m0gGR&IcE`+DY-W zH7}?LF!MO&oDyLn!4{Edtm$L6so!~nKnK@MpM}g~^$fRjbb{x0C^y_$S8f>f&TFFJ z&cJKjVz%CfAz=~5hQ{%U$*HVbK{;XhN}SV_%PPE;MA7H_Jmb&f>3^QD`1^Xt zpEq0nzS;Kj?dQLrPXGOW^Z)<(|9(FC|NF!Lp#~IxvM@3*)HCQX00AgY7}z&9)Hl^L zvv4$bbk;MmvbEQXafx*?v-Ys?@o_nE&1`03XJ=((=F>7?p~ct4#KOwXG=a-piA%|R zQavjJ3quo^i3yj>fkX9dyPGGPY*jiW#@1CYtEG2sRgCMXdACoQjJbxb2Cqk20JSggEatj@>Mzj literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/debugts_obj_g.gif b/core/org.eclipse.cdt.ui/icons/obj16/debugts_obj_g.gif new file mode 100644 index 0000000000000000000000000000000000000000..16a7b2c3ab20f38018d25a4f843890df88903898 GIT binary patch literal 596 zcmZ?wbhEHb6krfwIOfJ6ZWPPlRvThrz!0R);Mc?8*UJz(ogq;#&sUY9$gCwO@jOpx%l(uCv8dKJ`%Fk){ zU*D;)saI)MZ}GN?$}1*>ubULHYr5LLIU0LryYHRnv46gO(KgTd%kyft1|C@C)wA@{ z;ica9=i47zns{uL@7b+&Yj&Tzv@3J*smA~N?Qb1xxp?R4|NHU3?>7H_Jmb&f>3^QD z`1^XtpEq0nzS;Kj?dQLrPXGOW^Z)<(|9(FC|NF!LAq5nFvM@3*)HCQX00AgY7}z&9 z)Hl`hOPDlwbk=ifXtmc1F$s0?YxGEPa4)YM?-=TNs;q0Z67DWRdsIf2PS zo=M(fQoRPV1alLUsVS4|fkX8SyPGGPZk0bI#L!hQrLK2vRgCw?Ely3SF5a6_k eSwWI%1BbzjqpjRxNi`yc%FR4A8tkl04Aua;Em^?; literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/debugts_obj_r.gif b/core/org.eclipse.cdt.ui/icons/obj16/debugts_obj_r.gif new file mode 100644 index 0000000000000000000000000000000000000000..1df7e8c4521dc35ca16aaa87f223e2eb1c4e86d2 GIT binary patch literal 596 zcmZ?wbhEHb6krfwIOfJ6ZWOy+LV&@ocDt-_h=sv+C2fIsctva z-)^e3-Aq2uS9QC!Sxd5POPXAJrb1_q!h{^viFv9$1xj-=!X_80Pb*QMS)nO@ zOiJ6b8I37xTjl4p`>*d**wm{utG9UDMCBC|!q-iT*fm{k-yDrSv)%X3^VmP%{=g!y zo~4%#FZI4Z-~Q0j#AB;`&u*<-v-{koU77#)+uu6Ya`Dd7|M%m6-);W=c*dW{)BikQ z@%QzPKX11DeY5T5+s}VLo&Nj%=Kufm|NVUO|M!RgLkcMVWMO1rsAte&00K~)FtBfI zsBfz0EdmA{Z0vl}DK#dAix2bEXt1*~F<1it2%A=} literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/thread_obj_b.gif b/core/org.eclipse.cdt.ui/icons/obj16/thread_obj_b.gif new file mode 100644 index 0000000000000000000000000000000000000000..eb42ff75444dcf583e9637313ef36a32a3987863 GIT binary patch literal 360 zcmZ?wbhEHb6krfwSgOLnps3EEuE(Hf#$aQ|W)s0{Y~IA3H#^U7jN#rKi|H2Z)5Ym z#>q$9|L?aybnpD}2bcffkN^LF{{P<}{?h;`{$ycfV6bPJ}A&&Ve4wqSQx;=+H%P8LvVsqK~H1^P|r1&7ZWR5HaM}B zI&sR$aVodA+p~Fw%hm9=N7{39%RA>u%`S50mgN>w$W4?=DV{1VEyK;{6h391sIZ8L e7r4igECW3G`Ft&p~%FM`mkst4`0gx4F?4tZm!cyKPZQ|eCUeI5Y%9~*3coC z(6PaZq11^{UY=2j^ literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/thread_obj_r.gif b/core/org.eclipse.cdt.ui/icons/obj16/thread_obj_r.gif new file mode 100644 index 0000000000000000000000000000000000000000..95983d207813ac2c7424deef209445046120cf6f GIT binary patch literal 360 zcmZ?wbhEHb6krfwSgOh(ZWOy+LSVbBaEOJ$b|vxcI#S#9RJR-IZ#PxiZYH1StGeCV zOuof$PDYsRv=o8_xRuQqPFno1U#OlI`)kTRL686uxFW%gLf4+V5 z-p1yAjgybI|KD$a=-&C`4=(?|AOHXV{Qti{{HHch{K>+|z+lgy!vF*zKQXYi9+>|j z+(4)8#FPFB4l+|uI5lPdFlFOaeOTbZ!PRvzV?h89XWNm+55XxeA9^BZa7Zv+YveF$ z=-A-IQ0l}iFVC#f+HTL_87^NV&>m^e!=vDwCq28!nMaOCSTQ$II;D83jEpP~zf<^> jd14}>qT)OOPCP<_LOfDCcS-Q@Ej~DP`tef%jttfSlsdSm literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/threads_obj_b.gif b/core/org.eclipse.cdt.ui/icons/obj16/threads_obj_b.gif new file mode 100644 index 0000000000000000000000000000000000000000..588806dff37bf862424aa7daf8ba7aa78d8b6803 GIT binary patch literal 579 zcmZ?wbhEHb6krfwIOfE_ps3EEuE(Hf#$aQ|W)s0{*Uev$j=!PP_m5PK8aqO0#;4 zw@p-DF(G{2q=;S9)%MNN*fZOG?>vwF^X(5T@;bcK`~H0ULrW8nt@1s)weHfc%tJf2 z{@-tZ>sZT~V>|DhJbdNssb@E@{J$Un`)>2^$20ysp8n_gito?Q{eQ9R@9Q0Z-fa2% zX4~ISr~iJx`Tzg?e?Oo6|NY_rkOhiASr{1@>KSwxfB+OH4D1UU>YM7BSvZV-Ikx|rD6Ss9tRIPE#PxSE+*SlOBCxm1ids4Qz@Wnf{L#%V0WDPugN ziEV2Wr>-uisZT~V>|DhJbdNssb@E@{J$Un`)>2^$20ysp8n_gito?Q{eQ9R@9Q0Z z-fa2%X4~ISr~iJx`Tzg?e?Oo6|NY_r&;*JKSwxfB+OH4D1UU>YM7hMRc1x zI_p`LRNA{bxRrWD>iHP?x>%K!m6*9%7#$c{SejWyl$2TPSrkn+C@yPKViIAR#%LnR zC}}dIiD7FKqn;k4)6wJg44sBLRt9^I&#c#$lM~awA#JIyzNuN((VkcHiJ+1ClFju} z)@Gb)9|VjKbVyj3a;W~|pHQ#&Wk(^y5eGH~?H>;k9~^dKWeD_{q2PGbg^$5li;IQ9 F8UXC*UETly literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/threads_obj_r.gif b/core/org.eclipse.cdt.ui/icons/obj16/threads_obj_r.gif new file mode 100644 index 0000000000000000000000000000000000000000..b02c7ef63424166b632b9790528beb86f671b8aa GIT binary patch literal 579 zcmZ?wbhEHb6krfwIOfbCZWOy+LSVbBaEOJ$b|vxcI#S#9RJR-IZ#PxiZYH1StGeCV ztR-2tB~7k9Q=v0QVM31T#5~oW0;M?_VUr8hrYkv1hjX-gzGT=i47xi&9=XvPXGOW^Z)<(|9(FC|NF!Lp$Qa!vM@3*)HCQX00AgY7}ysy)Hl_$vT-+e zbk?(Qa82@;1FyV+32Saeefr7-NE&>e3T3jp) F)&QJ`UEKfx literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned.gif b/core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned.gif new file mode 100644 index 0000000000000000000000000000000000000000..282c7275f1f79506426c2709861c5aefe747a6fb GIT binary patch literal 359 zcmZ?wbhEHb6krfwSZc{2ZWNo9m1R(}%cX3UTls3Yiq*x%#da-+?OKo2)YMFvFd=Hr znb_IqV&|Oen7VGltQ8Yyt(*%43m42?v|#@7yohZtRE+-li+Yx~B& z{o6W^Z(PI|6hUV@Bbfv|9}7Y|Hr@oSb^eC7DfgJdj=f_ zAOQJ^fvx4h`~nXhseX?oN={xv!g2wZSAK9%KE&wQkdfjv<;e5Lh8iv0K1+?ARtgE8 zS9g>VVPS7`d&23$B;z8Z-qOlYE7IuPtfQ@?!_eQ~i$ZRaaME+C^O5(Adbp s*g(zLSjT=G|6p zwQRZ7vh~*XjeYyKbrc_Yv+C57)u*1!yz+7LjSssXemi>q%ic#{&p!Ef^WD$aKmWh} z_5U3Z{r>;{_y3Q-|9=9KfBt{^^ZzRl{r&&r@Bi=r{{Q&*9~V&k$->CMV9%h#00baE zF|f59m|x(bBh~Nmq@lq>h?Uj(vZaOtr_)iThaCk@;s+lFaPYMB^Rk&(EoEsryyk--`OE9bLl literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/elcl16/pin.gif b/core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_g.gif similarity index 100% rename from debug/org.eclipse.cdt.debug.ui/icons/elcl16/pin.gif rename to core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_g.gif diff --git a/core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_multi.gif b/core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_multi.gif new file mode 100644 index 0000000000000000000000000000000000000000..662d82967248b5eab6c6f28214ba03b539030795 GIT binary patch literal 357 zcmZ?wbhEHb6krfwSgOw;ZWPN9q|T72$53QuP_m0*s+~*OD!200ZWXKTS`OQ_9x= z|NFoHKmPqE11SDvVPs&iXV75)0+62=*qRQ^FYwTj>OYZ`crmhU(tgJ!muA}aw|10l z6qVv*aZPqu=)w}YWx~Xb1#I0Mu2$+&0xd2o8#q2NOS?!bv@le+F^V)gH!CqH^-Y-2 z?Ifk3qAWKIk^-9X@jO KaDay+gEaspA;4(> literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_r.gif b/core/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_r.gif new file mode 100644 index 0000000000000000000000000000000000000000..edcf9dc50b8bc720ef8b082b03e26fd0e357cd2f GIT binary patch literal 359 zcmZ?wbhEHb6krfwSZc{2ZWOy+LSVbB@OCBf?K)E1^;EYT>Tfqy+HNMl-P+8cWS2|X zD!200ZWXKTS`OQ_9*LTBCU*9@*g5AqrmmYXYsJJ_E9Wj;Fn7^{`OEVnw!K)ra{8)O z)AP4IYT0tDW$Uf&8~gTe>nJ|*X4R=Dt4}?ddFA8g8y|K({C4#Im%Wd^o_+G|=DVM- zfBt{{>;F3-`u+d?@Bbfv|NjIe|NQ^-=l@qA`uqRK-~ZqL{r~arKUSdllZBCi!Ja{f z0SG{TVqj}IFu%YE+-li+Yx~B& z{o6W^Z(PI|6hUV@Bbfv|9}7Y|Hr@oSb^eC7DfgJdj=f_ zAOQJ^fvx4h`~nXhseX?oN={xv!g2wZSAK9%KE&wQkdfjv<;e5Lh8iv0K1+?ARtgE8 zS9g>VVPS7`d&23$B;z8Z-qOlYE7IuPtfQ@?!_eQ~i$ZRaaME+C^O5(Adbp s*g(zLSjT= labels = new HashSet(); - Set handles = provider.getPinHandles(); - for (IPinElementHandle handle : handles) { + for (IPinElementHandle handle : provider.getPinHandles()) { String tmp = getLabel(handle); if (tmp != null && tmp.trim().length() != 0) labels.add(tmp); @@ -162,7 +166,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi for (String label : labels) { if (label != null) { if (description.length() > 0) { - description += "," + label; //$NON-NLS-1$ + description += ", " + label; //$NON-NLS-1$ } else { description = label; } @@ -176,16 +180,77 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi private String getLabel(IPinElementHandle handle) { String label = ""; //$NON-NLS-1$ - if (handle instanceof IAdaptable) { - IPinHandleLabelProvider provider = - (IPinHandleLabelProvider) ((IAdaptable) handle).getAdapter(IPinHandleLabelProvider.class); - if (provider != null) - label = provider.getLabel(); - } + if (handle != null) + label = handle.getLabel(); return label; } + private boolean useMultiPinImage(Set handles) { + if (handles.size() <= 1) return false; + + int overlayColor = IPinElementColorDescriptor.UNDEFINED; + ImageDescriptor imageDesc = null; + for (IPinElementHandle handle : handles) { + IPinElementColorDescriptor colorDesc = handle.getPinElementColorDescriptor(); + if (colorDesc != null) { + ImageDescriptor descImageDesc = colorDesc.getToolbarIconDescriptor(); + if (imageDesc != null && !imageDesc.equals(descImageDesc)) + return true; + imageDesc = descImageDesc; + + int descOverlayColor = colorDesc.getOverlayColor(); + if (overlayColor != IPinElementColorDescriptor.UNDEFINED && descOverlayColor != overlayColor) + return true; + overlayColor = descOverlayColor; + } + } + + return false; + } + + private void updatePinContextColor(DebugContextPinProvider provider) { + ImageDescriptor imageDesc = null; + if (provider != null) { + Set handles = provider.getPinHandles(); + + // if handles have different toolbar icon descriptor or different pin color, than use a + // multi-pin toolbar icon + if (useMultiPinImage(handles)) + imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_MULTI); + + if (imageDesc == null) { + Iterator itr = handles.iterator(); + if (itr.hasNext()) { + IPinElementHandle handle = itr.next(); + IPinElementColorDescriptor desc = handle.getPinElementColorDescriptor(); + if (desc != null) + imageDesc = desc.getToolbarIconDescriptor(); + + if (imageDesc == null && desc != null) { + int overlayColor = desc.getOverlayColor() % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT; + + switch (overlayColor) { + case IPinProvider.IPinElementColorDescriptor.GREEN: + imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_G); + break; + case IPinProvider.IPinElementColorDescriptor.RED: + imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_R); + break; + case IPinProvider.IPinElementColorDescriptor.BLUE: + imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_B); + break; + } + } + } + } + } + + if (imageDesc == null) + imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION); + fAction.setImageDescriptor(imageDesc); + } + /* (non-Javadoc) * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugContextPinProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugContextPinProvider.java index b6af12d62f7..054c68e64a1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugContextPinProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugContextPinProvider.java @@ -7,6 +7,7 @@ * * Contributors: * Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781) + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *****************************************************************/ package org.eclipse.cdt.debug.internal.ui.pinclone; @@ -93,20 +94,7 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem * @return true if the pinned handles are pinned to the debug context */ public boolean isPinnedTo(Object debugContext) { - IPinProvider pinProvider = null; - if (debugContext instanceof IAdaptable) { - pinProvider = (IPinProvider) ((IAdaptable)debugContext).getAdapter(IPinProvider.class); - } - - for (IPinElementHandle handle : fPinHandles) { - if (pinProvider != null && pinProvider.isPinnedTo(debugContext, handle)) { - return true; - - } else if (handle.getDebugContext().equals(debugContext)) { - return true; - } - } - return false; + return PinCloneUtils.isPinnedTo(fPinHandles, debugContext); } /** @@ -131,7 +119,7 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem handles.add(handle); fPinProvider.put(handle, pinProvider); } else - handles.add(new PinElementHandle(element, null)); + handles.add(new PinElementHandle(element, null, PinCloneUtils.getDefaultPinElementColorDescriptor())); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/PinCloneUtils.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/PinCloneUtils.java index 39e53d4543b..512a26d858d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/PinCloneUtils.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/PinCloneUtils.java @@ -7,15 +7,20 @@ * * Contributors: * Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781) + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *****************************************************************/ package org.eclipse.cdt.debug.internal.ui.pinclone; import java.lang.reflect.Method; import java.util.List; +import java.util.Set; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.IPinProvider; +import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor; +import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IViewPart; @@ -29,6 +34,29 @@ import org.eclipse.ui.part.WorkbenchPart; public class PinCloneUtils { public static String PIN_CLONE_VIEW_TAG = "PIN_CLONE_VIEW_"; //$NON-NLS-1$ + private static final DefaultPinElementColorDescriptor DEFAULT_PIN_ELEMENT_COLOR_DESCRIPTOR = new DefaultPinElementColorDescriptor(); + + /** + * Default pin element color descriptor. + */ + private static class DefaultPinElementColorDescriptor implements IPinElementColorDescriptor { + public int getOverlayColor() { + return GREEN; + } + public ImageDescriptor getToolbarIconDescriptor() { + return null; + } + } + + /** + * Returns the default pin element color descriptor. + * + * @return the color descriptor + */ + public static IPinElementColorDescriptor getDefaultPinElementColorDescriptor() { + return DEFAULT_PIN_ELEMENT_COLOR_DESCRIPTOR; + } + /** * Encodes cloned part secondary id. * @@ -42,10 +70,12 @@ public class PinCloneUtils { /** * Decodes cloned part secondary id. * - * @param secondaryId the part's secondary id. - * @return a decoded part secondary id. + * @param secondaryId the part's secondary id + * @return a decoded part secondary id */ public static String decodeClonedPartSecondaryId(String secondaryId) { + if (secondaryId == null) + return ""; //$NON-NLS-1$ return secondaryId.replaceFirst(PIN_CLONE_VIEW_TAG, ""); //$NON-NLS-1$ } @@ -168,4 +198,64 @@ public class PinCloneUtils { return pinnable; } + + /** + * Returns the pin element color descriptor for the set of handles. If there are multiple pinned handles, + * then return the default element color descriptor. + * + * @param handles the pinned debug handles + * @param debugContext the debug context to compare with against the handles + * @return the element color descriptor, can be null; + */ + public static IPinElementColorDescriptor getPinElementColorDescriptor(Set handles, Object debugContext) { + int color = IPinElementColorDescriptor.UNDEFINED; + IPinElementColorDescriptor colorDesc = null; + + for (IPinElementHandle handle : handles) { + if (debugContext instanceof IAdaptable) { + + IPinProvider pinProvider = (IPinProvider) ((IAdaptable) debugContext).getAdapter(IPinProvider.class); + if (pinProvider != null) { + if (pinProvider.isPinnedTo(debugContext, handle)) { + colorDesc = handle.getPinElementColorDescriptor(); + if (colorDesc != null) { + int overlayColor = colorDesc.getOverlayColor(); + if (color == IPinElementColorDescriptor.UNDEFINED) color = overlayColor; + if (color != overlayColor) { + colorDesc = null; + break; + } + } + } + } + } + } + + if (colorDesc == null) + colorDesc = getDefaultPinElementColorDescriptor(); + + return colorDesc; + } + + /** + * Returns whether the debug context is pinned to any one of these handles. + * + * @param handles the handles + * @param debugContext the debug context + * @return true if pinned to any one of these handles + */ + public static boolean isPinnedTo(Set handles, Object debugContext) { + for (IPinElementHandle handle : handles) { + if (debugContext instanceof IAdaptable) { + IPinProvider pinProvider = (IPinProvider) ((IAdaptable) debugContext).getAdapter(IPinProvider.class); + if (pinProvider != null) { + if (pinProvider.isPinnedTo(debugContext, handle)) { + return true; + } + } + } + } + + return false; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/IPinProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/IPinProvider.java index c678677a8bd..efa8c76d55c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/IPinProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/IPinProvider.java @@ -7,9 +7,11 @@ * * Contributors: * Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781) + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *****************************************************************/ package org.eclipse.cdt.debug.ui; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchPart; /** @@ -29,17 +31,49 @@ import org.eclipse.ui.IWorkbenchPart; */ public interface IPinProvider { /** - * An interface that provides label for the pinned handle. Handle that - * wish to provide custom label should implement this interface. + * Pin element color descriptor. */ - public interface IPinHandleLabelProvider { + public interface IPinElementColorDescriptor { /** - * Returns the label the label will be used to display - * in the pinned view's descriptor. - * - * @return the handle label + * Default number of color count. */ - String getLabel(); + final int DEFAULT_COLOR_COUNT = 3; + + /** + * An undefined color + */ + int UNDEFINED = -1; + + /** + * Green color (Default) + */ + int GREEN = 0; + + /** + * Red color + */ + int RED = 1; + + /** + * Blue color + */ + int BLUE = 2; + + /** + * Returns the overlay pin color. The overlay pin will be used to decorate the debug view for element that + * is pinned to a view. + * + * @return one of the overlay color + */ + int getOverlayColor(); + + /** + * Returns the toolbar pin action image description to use when the view is pinned, can be null. + * If null, than the default image description will be use. + * + * @return the icon descriptor + */ + ImageDescriptor getToolbarIconDescriptor(); } /** @@ -51,7 +85,22 @@ public interface IPinProvider { * * @return the debug context */ - Object getDebugContext(); + Object getDebugContext(); + + /** + * Returns the label the label will be used to display + * in the pinned view's descriptor. + * + * @return the handle label + */ + String getLabel(); + + /** + * Returns color descriptor for this element. + * + * @return the color descriptor, can be null + */ + IPinElementColorDescriptor getPinElementColorDescriptor(); } /** diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/PinElementHandle.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/PinElementHandle.java index 43a4f93739e..df13a90df2d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/PinElementHandle.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/PinElementHandle.java @@ -7,11 +7,12 @@ * * Contributors: * Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781) + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *****************************************************************/ package org.eclipse.cdt.debug.ui; +import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor; import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle; -import org.eclipse.cdt.debug.ui.IPinProvider.IPinHandleLabelProvider; import org.eclipse.core.runtime.PlatformObject; /** @@ -19,23 +20,34 @@ import org.eclipse.core.runtime.PlatformObject; * * @since 7.1 */ -public class PinElementHandle extends PlatformObject implements IPinHandleLabelProvider, IPinElementHandle { - private final Object fDebugContext; - private final String fLabel; +public class PinElementHandle extends PlatformObject implements IPinElementHandle { + private Object fDebugContext; + private String fLabel; + private IPinElementColorDescriptor fColorDescriptor; - public PinElementHandle(Object debugContext, String label) { + public PinElementHandle(Object debugContext, String label, IPinElementColorDescriptor colorDescriptor) { fDebugContext = debugContext; fLabel = label; + fColorDescriptor = colorDescriptor; } /* * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle#getDebugContext() */ - public Object getDebugContext() { + public synchronized Object getDebugContext() { return fDebugContext; } + /** + * Sets the debug context. + * + * @param debugContext the new debug context + */ + public synchronized void setDebugContext(Object debugContext) { + fDebugContext = debugContext; + } + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.core.IPinProvider.IHandleLabelProvider#getLabel() @@ -43,7 +55,15 @@ public class PinElementHandle extends PlatformObject implements IPinHandleLabelP public String getLabel() { return fLabel; } - + + /* + * (non-Javadoc) + * @see org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle#getPinElementColorDescriptor() + */ + public IPinElementColorDescriptor getPinElementColorDescriptor() { + return fColorDescriptor; + } + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java index 206ae4a1ffa..24fe859fdc7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java @@ -8,6 +8,7 @@ * Contributors: * Wind River Systems - initial API and implementation * Navid Mehregani (TI) - Bug 289526 - Migrate the Restart feature to the new one, as supported by the platform + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui; @@ -172,7 +173,7 @@ public class GdbAdapterFactory fSaveTraceDataTarget = new GdbSaveTraceDataCommand(session); fSelectNextRecordTarget = new GdbSelectNextTraceRecordCommand(session); fSelectPrevRecordTarget = new GdbSelectPrevTraceRecordCommand(session); - fPinProvider = new GdbPinProvider(); + fPinProvider = new GdbPinProvider(session); session.registerModelAdapter(ISteppingModeTarget.class, fSteppingModeTarget); session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand); @@ -285,6 +286,7 @@ public class GdbAdapterFactory fSaveTraceDataTarget.dispose(); fSelectNextRecordTarget.dispose(); fSelectPrevRecordTarget.dispose(); + fPinProvider.dispose(); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinColorTracker.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinColorTracker.java new file mode 100644 index 00000000000..8896d957e8c --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinColorTracker.java @@ -0,0 +1,83 @@ +/***************************************************************** + * Copyright (c) 2011 Texas Instruments and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) + *****************************************************************/ +package org.eclipse.cdt.dsf.gdb.internal.ui; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor; + +/** + * This class tracks the color for the pinned context. + */ +class GdbPinColorTracker { + private class Pair { + Integer refCount; + String context; + Pair(String context, Integer refCount) { + this.context = context; + this.refCount = refCount; + } + } + + private static List gsColorBuckets = Collections.synchronizedList( new ArrayList() ); + + /** + * The static instance. + */ + static GdbPinColorTracker INSTANCE = new GdbPinColorTracker(); + + /** + * Singleton object - make constructor private. + */ + private GdbPinColorTracker() {} + + int addRef(String context) { + if (context == null) return IPinElementColorDescriptor.UNDEFINED; + + // look in the buckets and see if it is already exist + for (int i = 0; i < gsColorBuckets.size(); ++i) { + Pair pair = gsColorBuckets.get(i); + if (pair.context.equals(context) && pair.refCount > 0) { + pair.refCount++; + return i % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT; + } + } + + // if not exist in the buckets, then add to the bucket collection + int size = gsColorBuckets.size(); + int index = size; + for (int i = 0; i < size; ++i) { + Pair pair = gsColorBuckets.get(i); + if (pair.refCount <= 0) { + index = i; + gsColorBuckets.remove(index); + break; + } + } + gsColorBuckets.add(index, new Pair(context, 1)); + return (index) % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT; + } + + void removeRef(String context) { + if (context == null) return; + + for (int i = 0; i < gsColorBuckets.size(); ++i) { + Pair pair = gsColorBuckets.get(i); + if (pair.context.equals(context)) { + pair.refCount--; + + return; + } + } + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java index 58259f04239..aa07c2814a0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java @@ -7,14 +7,20 @@ * * Contributors: * Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781) + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *****************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import org.eclipse.cdt.debug.ui.IPinProvider; import org.eclipse.cdt.debug.ui.PinElementHandle; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.ImmediateInDsfExecutor; import org.eclipse.cdt.dsf.concurrent.Query; import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.IDMContext; @@ -22,59 +28,125 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses; import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; +import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.StateChangedEvent; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; +import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchPart; /** * GDB pin provider implementation. */ public class GdbPinProvider implements IPinProvider { - - private IMIExecutionDMContext getExecutionDmc(IDMContext dmc) { - return DMContexts.getAncestorOfType(dmc, IMIExecutionDMContext.class); - + private static class GdbPinElementColorDescriptor implements IPinElementColorDescriptor { + int fColor = GREEN; + + GdbPinElementColorDescriptor(int color) { + fColor = color; + } + public int getOverlayColor() { + return fColor; + } + public ImageDescriptor getToolbarIconDescriptor() { + return null; + } } - private IProcessDMContext getProcessDmc(IDMContext dmc) { + /** + * A set of pinned element handles. + */ + static private Set gsPinnedHandles = Collections.synchronizedSet(new HashSet()); + + /** + * Dsf session. + */ + private final DsfSession fSession; + + /** + * Constructor. + * + * @param session + */ + public GdbPinProvider(DsfSession session) { + fSession = session; + + session.getExecutor().execute(new Runnable() { + public void run() { + fSession.addServiceEventListener(GdbPinProvider.this, null); + } + }); + } + + /** + * Dispose all resources. + */ + public void dispose() { + try { + fSession.getExecutor().execute(new Runnable() { + public void run() { + fSession.removeServiceEventListener(GdbPinProvider.this); + } + }); + } catch (RejectedExecutionException e) { + // Session already gone. + } + } + + /** + * Returns the pinned element handles. + * + * @return the element handles. + */ + public static Set getPinnedHandles() { + return gsPinnedHandles; + } + + private static IMIExecutionDMContext getExecutionDmc(IDMContext dmc) { + return DMContexts.getAncestorOfType(dmc, IMIExecutionDMContext.class); + } + + private static IProcessDMContext getProcessDmc(IDMContext dmc) { return DMContexts.getAncestorOfType(dmc, IProcessDMContext.class); } private IThreadDMData getData(final IThreadDMContext threadDmc) { - if (threadDmc == null) - return null; + if (threadDmc == null || !fSession.isActive()) + return null; - IThreadDMData data = null; - try { - String sessionId = threadDmc.getSessionId(); - DsfSession session = DsfSession.getSession(sessionId); - final DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), sessionId); - - try { - if (tracker != null) { - Query query = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - final IProcesses processes = tracker.getService(IProcesses.class); - if (processes != null) { - processes.getExecutionData(threadDmc, rm); - } - } - }; - - session.getExecutor().execute(query); - data = query.get(1, TimeUnit.SECONDS); + IThreadDMData data = null; + final DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); + try { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + final IProcesses processes = tracker.getService(IProcesses.class); + if (processes != null) { + processes.getExecutionData(threadDmc, rm); + } else { + rm.setData(null); + rm.done(); + } } - } finally { - if (tracker != null) - tracker.dispose(); - } - } catch (Exception e) { - } - - return data; + }; + + ImmediateInDsfExecutor immediateExecutor = new ImmediateInDsfExecutor(fSession.getExecutor()); + immediateExecutor.execute(query); + data = query.get(2, TimeUnit.SECONDS); // timeout in 2 seconds, in case the call to execute got stuck + } catch (Exception e) { + GdbUIPlugin.log(e); + } finally { + if (tracker != null) + tracker.dispose(); + } + return data; } private String getLabel(IThreadDMData data) { @@ -122,19 +194,38 @@ public class GdbPinProvider implements IPinProvider { public IPinElementHandle pin(IWorkbenchPart part, Object debugContext) { Object pinContext = debugContext; String label = ""; //$NON-NLS-1$ + String sessionId = ""; //$NON-NLS-1$ + IDMContext dmc = null; if (debugContext instanceof IAdaptable) { - IDMContext dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class); + dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class); + sessionId = dmc.getSessionId() + "."; //$NON-NLS-1$ + if (dmc != null) { IMIExecutionDMContext execDmc = getExecutionDmc(dmc); IProcessDMContext processDmc = getProcessDmc(dmc); label = getCombinedLabels(processDmc, execDmc); - if (execDmc != null) + + // set the pin context to a thread if it exist + if (execDmc != null) { + dmc = execDmc; pinContext = execDmc; + + // otherwise, set it to the DM context + } else { + pinContext = dmc; + } } } - return new PinElementHandle(pinContext, label); + + IPinElementColorDescriptor colorDesc = + new GdbPinElementColorDescriptor(GdbPinColorTracker.INSTANCE.addRef(sessionId + label)); + PinElementHandle handle = new PinElementHandle(pinContext, label, colorDesc); + gsPinnedHandles.add(handle); + dispatchChangedEvent(dmc); + + return handle; } /* @@ -142,7 +233,17 @@ public class GdbPinProvider implements IPinProvider { * @see org.eclipse.cdt.debug.ui.IPinProvider#unpin(org.eclipse.ui.IWorkbenchPart, org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle) */ public void unpin(IWorkbenchPart part, IPinElementHandle handle) { - // do nothing for now. + // remove the handle from the cache + gsPinnedHandles.remove(handle); + + // dispatch the event to update the handle DM context + Object debugContext = handle.getDebugContext(); + if (debugContext instanceof IAdaptable) { + IDMContext dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class); + GdbPinColorTracker.INSTANCE.removeRef(dmc.getSessionId() + handle.getLabel()); + dispatchChangedEvent(dmc); + + } } /* @@ -150,19 +251,82 @@ public class GdbPinProvider implements IPinProvider { * @see org.eclipse.cdt.debug.ui.IPinProvider#isPinnedTo(java.lang.Object, org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle) */ public boolean isPinnedTo(Object debugContext, IPinElementHandle handle) { - if (debugContext instanceof IAdaptable) { + Object handleDebugContext = handle.getDebugContext(); + + if (debugContext instanceof IAdaptable && handleDebugContext instanceof IAdaptable) { IDMContext dmc = (IDMContext) ((IAdaptable) debugContext).getAdapter(IDMContext.class); - if (dmc != null) { - IMIExecutionDMContext execDmc = getExecutionDmc(dmc); - IProcessDMContext processDmc = getProcessDmc(dmc); - - if (execDmc != null && processDmc != null ) { + IDMContext hDmc = (IDMContext) ((IAdaptable) handleDebugContext).getAdapter(IDMContext.class); + + if (dmc != null && hDmc != null) { + if (dmc.getSessionId().equals(hDmc.getSessionId())) { + IMIExecutionDMContext execDmc = getExecutionDmc(dmc); + IProcessDMContext processDmc = getProcessDmc(dmc); + String label = getCombinedLabels(processDmc, execDmc); - if (handle instanceof IPinHandleLabelProvider) - return label.equals( ((IPinHandleLabelProvider)handle).getLabel() ); + return label.equals(handle.getLabel()); } } } return false; } + + /** + * Dispatch the change event for the given DM context. + * + * @param dmc the DM context + */ + private void dispatchChangedEvent(IDMContext dmc) { + if (dmc == null) + return; + + try { + DsfSession session = DsfSession.getSession(dmc.getSessionId()); + if (session != null && session.isActive()) + session.dispatchEvent(new StateChangedEvent(dmc), null); + } catch (RejectedExecutionException e) { + // Session already gone. + } + } + + /** + * Handle start event and re-attach the DM context to the pinned handles. The DM context + * is used for dispatching event to update the element label. + */ + @DsfServiceEventHandler + public void handleEvent(final IStartedDMEvent event) { + final IDMContext eventDmc = event.getDMContext(); + final IMIExecutionDMContext eventExecDmc = getExecutionDmc(eventDmc); + final IProcessDMContext eventProcessDmc = getProcessDmc(eventDmc); + + if (eventProcessDmc != null) { + for (final IPinElementHandle h : gsPinnedHandles) { + new Job("Updating pin handler debug context") { //$NON-NLS-1$ + {setPriority(INTERACTIVE);} + @Override + protected IStatus run(IProgressMonitor monitor) { + // only attach to the same pin handle if the session is not active + PinElementHandle handle = ((PinElementHandle)h); + Object handleDebugContext = handle.getDebugContext(); + if (handleDebugContext instanceof IAdaptable) { + IDMContext handleDmc = (IDMContext) ((IAdaptable) handleDebugContext).getAdapter(IDMContext.class); + if (handleDmc != null) { + DsfSession session = DsfSession.getSession(handleDmc.getSessionId()); + if (session == null || !session.isActive()) { + String handleLabel = handle.getLabel(); + String label = getCombinedLabels(eventProcessDmc, eventExecDmc); + + if (label.equals(handleLabel)) { + IDMContext newDmc = eventExecDmc != null ? eventExecDmc : eventDmc; + handle.setDebugContext(newDmc); + dispatchChangedEvent(newDmc); + } + } + } + } + return Status.OK_STATUS; + } + }.schedule(); + } + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java index f8943da33b8..76233d36347 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java @@ -8,13 +8,17 @@ * Contributors: * Ericsson - Initial API and implementation * Wind River Systems - Factored out AbstractContainerVMNode + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch; +import java.util.Map; import java.util.concurrent.RejectedExecutionException; +import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils; +import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor; import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; @@ -29,6 +33,7 @@ import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommand import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractContainerVMNode; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants; +import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData; import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; import org.eclipse.cdt.dsf.service.DsfSession; @@ -44,6 +49,7 @@ import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelImage; import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText; import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider; import org.eclipse.cdt.dsf.ui.viewmodel.properties.VMDelegatingPropertiesUpdate; +import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.core.runtime.IStatus; import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest; @@ -86,15 +92,109 @@ public class ContainerVMNode extends AbstractContainerVMNode IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN, IGdbLaunchVMConstants.PROP_CORES_ID }), new LabelText(MessagesForGdbLaunchVM.ContainerVMNode_No_columns__Error__label, new String[0]), - new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_SUSPENDED)) { + + /* RUNNING CONTAINER - RED PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_R_PINNED)) { + { setPropertyNames(new String[] { + ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) ? + !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; + }; + }, + /* RUNNING CONTAINER - GREEN PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_G_PINNED)) { + { setPropertyNames(new String[] { + ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) ? + !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; + }; + }, + /* RUNNING CONTAINER - BLUE PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_B_PINNED)) { + { setPropertyNames(new String[] { + ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) ? + !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; + }; + }, + /* RUNNING CONTAINER - NO PIN */ + new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET)) { { setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); } @Override public boolean isEnabled(IStatus status, java.util.Map properties) { - return Boolean.TRUE.equals(properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED)); + return Boolean.FALSE.equals(properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED)); }; }, - new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET)), + + /* SUSPENDED CONTAINER - RED PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_R_PINNED)) { + { setPropertyNames(new String[] { + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? + pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; + }; + }, + /* SUSPENDED CONTAINER - GREEN PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_G_PINNED)) { + { setPropertyNames(new String[] { + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? + pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; + }; + }, + /* SUSPENDED CONTAINER - BLUE PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_B_PINNED)) { + { setPropertyNames(new String[] { + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? + pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; + }; + }, + /* SUSPENDED CONTAINER - NO PIN */ + new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_SUSPENDED)), })); return provider; @@ -139,6 +239,14 @@ public class ContainerVMNode extends AbstractContainerVMNode // standard container properties. parentUpdates[i] = new VMDelegatingPropertiesUpdate(updates[i], countringRm); count++; + + // set pin properties + IDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IDMContext.class); + IPinElementColorDescriptor colorDesc = PinCloneUtils.getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), dmc); + updates[i].setProperty(IGdbLaunchVMConstants.PROP_PIN_COLOR, + colorDesc != null ? colorDesc.getOverlayColor() : null); + updates[i].setProperty(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), dmc)); if (update.getProperties().contains(PROP_NAME) || update.getProperties().contains(ILaunchVMConstants.PROP_ID) || diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/IGdbLaunchVMConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/IGdbLaunchVMConstants.java index a78d5a420db..2ed87113c9b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/IGdbLaunchVMConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/IGdbLaunchVMConstants.java @@ -7,6 +7,7 @@ * * Contributors: * Wind River Systems - initial API and implementation + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch; @@ -29,4 +30,13 @@ public interface IGdbLaunchVMConstants { */ public static final String PROP_CORES_ID_KNOWN = "cores_id_known"; //$NON-NLS-1$ + /** + * The context is pinned. Value true or false. + */ + public static final String PROP_PINNED_CONTEXT = "pinned_context"; //$NON-NLS-1$ + + /** + * The pin color. One of the IPinElementColorDescriptor color value. + */ + public static final String PROP_PIN_COLOR = "pin_color"; //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java index 9627a4bf39d..4b56d0dee91 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java @@ -8,9 +8,14 @@ * Contributors: * Wind River Systems - initial API and implementation * Ericsson - Modified for multi threaded functionality + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch; +import java.util.Map; + +import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils; +import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.datamodel.IDMContext; @@ -20,6 +25,7 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractThreadVMNode; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants; +import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData; import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; @@ -35,6 +41,7 @@ import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelImage; import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText; import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider; import org.eclipse.cdt.dsf.ui.viewmodel.properties.VMDelegatingPropertiesUpdate; +import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.core.runtime.IStatus; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider; @@ -61,7 +68,7 @@ public class ThreadVMNode extends AbstractThreadVMNode @Override protected IElementLabelProvider createLabelProvider() { PropertiesBasedLabelProvider provider = new PropertiesBasedLabelProvider(); - + provider.setColumnInfo( PropertiesBasedLabelProvider.ID_COLUMN_NO_COLUMNS, new LabelColumnInfo(new LabelAttribute[] { @@ -83,6 +90,55 @@ public class ThreadVMNode extends AbstractThreadVMNode ExecutionContextLabelText.PROP_STATE_CHANGE_DETAILS_KNOWN, ILaunchVMConstants.PROP_STATE_CHANGE_DETAILS}), new LabelText(MessagesForGdbLaunchVM.ThreadVMNode_No_columns__Error__label, new String[0]), + /* RUNNING THREAD - RED PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_R_PINNED)) { + { setPropertyNames(new String[] { + ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) ? + !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; + }; + }, + /* RUNNING THREAD - GREEN PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_G_PINNED)) { + { setPropertyNames(new String[] { + ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) ? + !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; + }; + }, + /* RUNNING THREAD - BLUE PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_B_PINNED)) { + { setPropertyNames(new String[] { + ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) ? + !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; + }; + }, + /* RUNNING THREAD - NO PIN */ new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING)) { { setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); } @@ -93,6 +149,49 @@ public class ThreadVMNode extends AbstractThreadVMNode return (prop != null) ? !prop.booleanValue() : false; }; }, + /* SUSPENDED THREAD - RED PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_R_PINNED)) { + { setPropertyNames(new String[] { + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? + pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; + }; + }, + /* SUSPENDED THREAD - GREEN PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_G_PINNED)) { + { setPropertyNames(new String[] { + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? + pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; + }; + }, + /* SUSPENDED THREAD - BLUE PIN */ + new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_B_PINNED)) { + { setPropertyNames(new String[] { + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + + @Override + public boolean isEnabled(IStatus status, Map properties) { + Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? + pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; + }; + }, + /* SUSPENDED THREAD - NO PIN */ new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED)), })); return provider; @@ -118,6 +217,13 @@ public class ThreadVMNode extends AbstractThreadVMNode update.getViewerInput(), update.getElementPath(), IMIExecutionDMContext.class); if (execDmc != null) { update.setProperty(ILaunchVMConstants.PROP_ID, Integer.toString(execDmc.getThreadId())); + + // set pin properties + IPinElementColorDescriptor colorDesc = PinCloneUtils.getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), execDmc); + updates[i].setProperty(IGdbLaunchVMConstants.PROP_PIN_COLOR, + colorDesc != null ? colorDesc.getOverlayColor() : null); + updates[i].setProperty(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), execDmc)); } if (update.getProperties().contains(PROP_NAME) || diff --git a/dsf/org.eclipse.cdt.dsf.ui/icons/pin.gif b/dsf/org.eclipse.cdt.dsf.ui/icons/pin.gif deleted file mode 100644 index 0f13a0ec5b3c8f5bc4094ecdaa9d2e10dcc8e4c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 358 zcmZ?wbhEHb6krfwSZcx0F?F4|QS8K7D<{laVNkNmrEHa3`D(X{)po5%>{<@T&OW#5 z)RWbxo*cdZC3eoamMynhw%$7X>;K2!|G)nE|Ksof*T4S1`~Cm@@BbhF{Qval|JT3&fBgIZ{ont&3m42? zw1A<=j3H5vAxNEJs-5ZVh@x$twOa!hpK6@HJa5&i>8n>x-@dVL|F(|*IDq0$7DfgJ zdj=f_AOQJ^fvx$#`~nXhseX?ouT{N;!Z$=*e%a(0f2gUkp}(JdYNg z%m~wum=R$iAjHMNe64D0o{Kqea|>gQaf5S{qKu*7ZYA- vRTVi^ISEx&Qx`2>HTex2E+-li+Yx~B& z{o6W^Z(PI|6hUV@Bbfv|9}7Y|Hr@oSb^eC7DfgJdj=f_ zAOQJ^fvx4h`~nXhseX?oN={xv!g2wZSAK9%KE&wQkdfjv<;e5Lh8iv0K1+?ARtgE8 zS9g>VVPS7`d&23$B;z8Z-qOlYE7IuPtfQ@?!_eQ~i$ZRaaME+C^O5(Adbp s*g(zLSjT= { + + public StateChangedEvent(IDMContext context) { + super(context); + } +} diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/icons/pin.gif b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/icons/pin.gif deleted file mode 100644 index 0f13a0ec5b3c8f5bc4094ecdaa9d2e10dcc8e4c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 358 zcmZ?wbhEHb6krfwSZcx0F?F4|QS8K7D<{laVNkNmrEHa3`D(X{)po5%>{<@T&OW#5 z)RWbxo*cdZC3eoamMynhw%$7X>;K2!|G)nE|Ksof*T4S1`~Cm@@BbhF{Qval|JT3&fBgIZ{ont&3m42? zw1A<=j3H5vAxNEJs-5ZVh@x$twOa!hpK6@HJa5&i>8n>x-@dVL|F(|*IDq0$7DfgJ zdj=f_AOQJ^fvx$#`~nXhseX?ouT{N;!Z$=*e%a(0f2gUkp}(JdYNg z%m~wum=R$iAjHMNe64D0o{Kqea|>gQaf5S{qKu*7ZYA- vRTVi^ISEx&Qx`2>HTex2E+-li+Yx~B& z{o6W^Z(PI|6hUV@Bbfv|9}7Y|Hr@oSb^eC7DfgJdj=f_ zAOQJ^fvx4h`~nXhseX?oN={xv!g2wZSAK9%KE&wQkdfjv<;e5Lh8iv0K1+?ARtgE8 zS9g>VVPS7`d&23$B;z8Z-qOlYE7IuPtfQ@?!_eQ~i$ZRaaME+C^O5(Adbp s*g(zLSjT=