From 9c012821f15cb20002b4f0b0b73ebb8648827825 Mon Sep 17 00:00:00 2001 From: Fabian Brosig <fabian.brosig@uni-wuerzburg.de> Date: Thu, 18 Oct 2012 18:38:23 +0000 Subject: [PATCH] splittep up repository into repository and repository_composites git-svn-id: https://se1.informatik.uni-wuerzburg.de/usvn/svn/code/code/DMM/trunk@8873 9e42b895-fcda-4063-8a3b-11be15eb1bbd --- .../obj16/RepositoryCompositesModelFile.gif | Bin 0 -> 346 bytes .../obj16/Repository_compositesModelFile.gif | Bin 0 -> 346 bytes .../full/wizban/NewRepositoryComposites.gif | Bin 0 -> 2462 bytes .../full/wizban/NewRepository_composites.gif | Bin 0 -> 2462 bytes .../plugin.properties | 12 + .../ApplicationlevelEditorPlugin.java | 101 - .../FunctionsActionBarContributor.java | 426 ---- .../presentation/FunctionsEditor.java | 1839 ----------------- .../presentation/FunctionsModelWizard.java | 630 ------ ...meterdependenciesActionBarContributor.java | 426 ---- .../ParameterdependenciesEditor.java | 1839 ----------------- .../ParameterdependenciesModelWizard.java | 630 ------ .../RepositoryActionBarContributor.java | 426 ---- ...sitoryCompositesActionBarContributor.java} | 16 +- .../RepositoryCompositesEditor.java} | 45 +- .../RepositoryCompositesModelWizard.java} | 53 +- .../presentation/ServicebehaviorEditor.java | 1839 ----------------- .../ServicebehaviorModelWizard.java | 630 ------ .../SystemActionBarContributor.java | 426 ---- .../mm/system/presentation/SystemEditor.java | 1839 ----------------- .../presentation/SystemModelWizard.java | 630 ------ 21 files changed, 71 insertions(+), 11736 deletions(-) create mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/obj16/RepositoryCompositesModelFile.gif create mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/obj16/Repository_compositesModelFile.gif create mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/wizban/NewRepositoryComposites.gif create mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/wizban/NewRepository_composites.gif delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/applicationlevel/presentation/ApplicationlevelEditorPlugin.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsActionBarContributor.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsEditor.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsModelWizard.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesActionBarContributor.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesEditor.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesModelWizard.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryActionBarContributor.java rename edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/{servicebehavior/presentation/ServicebehaviorActionBarContributor.java => repository_composites/presentation/RepositoryCompositesActionBarContributor.java} (96%) rename edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/{repository/presentation/RepositoryEditor.java => repository_composites/presentation/RepositoryCompositesEditor.java} (97%) rename edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/{repository/presentation/RepositoryModelWizard.java => repository_composites/presentation/RepositoryCompositesModelWizard.java} (87%) delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorEditor.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorModelWizard.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemActionBarContributor.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemEditor.java delete mode 100644 edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemModelWizard.java diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/obj16/RepositoryCompositesModelFile.gif b/edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/obj16/RepositoryCompositesModelFile.gif new file mode 100644 index 0000000000000000000000000000000000000000..74c1ecf572335d601f6063e5f6cd326c7cac6996 GIT binary patch literal 346 zcmZ?wbhEHb6krfwxXQrL(9jScAHRS9{{Q#qA2@IT$YuD?z`*by$o~Hy%=!;v&zUpl zK!XDiY?)vSL>v0;*7P_m?{-?$;XJq1b$XLqbGdI_sb6(*z?DszxAxXNIMM&}*Prh{ ze}Db)`_tFoAHM#6`{~!K4?pj}{Bh^`cc2B-0*XIb7#SGY7<51eg8an5R_@ST;GrX= zctYipMoY!K3%o6wKO@%5tSn@DRb_qCbE1$|yWBH@r4fQVIr*ESLo}n@ez-qul#lEZ zS5e_*ZQ*SacV#MQWoap7a^<h$WtrB`-_<j<pJk$pgsN&=>mmtPNwrl~{HxR?U8Ocj S6|iiU@^NC~pYP(xU=0A_Z+Kt; literal 0 HcmV?d00001 diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/obj16/Repository_compositesModelFile.gif b/edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/obj16/Repository_compositesModelFile.gif new file mode 100644 index 0000000000000000000000000000000000000000..682f807656d4841b21cf23bd7966354b9e2b52d2 GIT binary patch literal 346 zcmZ?wbhEHb6krfwxXQrL(9jScAHRS9{{Q#qA2@IT$YuD?z`*by$o~Hy%=-U-&x<`h zH+#~~q&XaL*fPNuh&J@wt?6-C-tDxg!+CD2>+~kK=5pV<QorirfGe9aZ|$vlaH9X` zuRq^^{{H&o_ouJFKYacD_S3IdAAa6{`Qy&>??4Nv1r&d>FfuT(G3bB{1o?@9t=yrx zz(Yq!@r24Hjh2de7kFDVe@3jASy{;Rs>=GN=R_f`cDZK)OCtn#a`HDthiFE*{cwNS zC?DA+uA;)r+QQo;?#fiq%F<HE<jP;g%QCH>zpH0zKg&cH302j$)<qJol4`4}_*bb( Wx=L-5Dqz_x<>SP}Ki|cX!5RS3-+46v literal 0 HcmV?d00001 diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/wizban/NewRepositoryComposites.gif b/edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/wizban/NewRepositoryComposites.gif new file mode 100644 index 0000000000000000000000000000000000000000..cda87bb85c10302d324f33b4c18991854821b11b GIT binary patch literal 2462 zcmd6m`8OMg9>vr0W`ro+QPZJfTAHHK&QR6SQfo}hXceuc!Psh7wTu@PbYh9bnkHgN ztd-a$u{9MXi7+%uRH8(R2pUTlqcf)7U-9nwocrVV-0wN}+Bw*onfo~bt^qy)_O!dZ zySDy$ZT%CSH8I2&5Ao+D(v8*i&la9pmR{MGURg{glRzLa5msMi?U#2Qj<xa2vxQ@A z;TZdXeCObz8=)mPLW^A<;9MWz+#;U3M-kkk@Sd?m&)Cv?@#Q`VmA-paz>`RUDOJI# zHDPIW5gE@SGwNghpghcOOhh;Tj&1!N(~?$9Ll)CerCnL2-53%RyT|jw>ONduKdz2N zXc#DKWS8$TNN(ZQ(?_UXqcqk8y??TgCuEP!@~4-^rxzzgQo-Bh8OfSZys{wMlt|Yv z-_5>qFURt3*3aI#KYQm~^+ns<|M~^SE+F65ALIC20W7%CB^>7(j&qBA>K;vSkH&k% z5<T|9m-!}E`Xp5NCRV_cNdYNUVaU2rWNi$J5|`bWfNn+<wx^ZQkR`NCJOf4SMiIMm z%6oDvdUGp!Fk~i{%*2qMW6003<mZJoFL3q!<xT9e#=-KYK~gKXx}8@?AE9)OQoBc+ zdtbG^81EVs^m5+3;0XuEW{1Yb!xNIxsfCeA34eO=wMZ(GtWAqoW*6SiNLE+mA4}?4 z1j@^@uLqk3t2=m<?onF*L@)PE|DQALSF_ylIlgddbn4y6<ov{pRI<DwUXm}r|G2ce zHTY_FcygXETzowv70fQbU3f2&tWJw%GWo~l_aBy4H{Wl5UfcMzu(ByxUSC?<THW}x zMfKU5ZrPk0nC!1=Z!Ik*6=&d!k_)kMm^^rDI<dK>me$tY$N0*?U`IEjp%RbnVGX{W zo#74qIl>+r<4sHn=Kt5V|2u>1CED8pKxr4CprmczRQ@7O>9FD5Ad_SJT|s(|1hX;S zx-4~r5aF5gMTkrd<7jOMtS=-}$2t(gX_<E@Fg)KusFV8x&<1cSnX?%PDN~AGUYX)A zaLTX250wUQ1>JOYur@k3bphZ?z8QxibgtJ-;@vB33sEM;Q>{V#dgq<|Irm0)R){E3 z-5nap*;p10(ITi`oss8~cc5#mnwZ1lkO^88*&l7EPij|m1>d6q^pcZI5eRgK+G*Qb zr@~-9#g&FS0>p;elY%(Jb9j%yVO5Kyzd>4O#ba^#b*_}BaiN}+duY#JP8^%%b;6=k zw#~Qh;K;X5pY476VdY)(Z>(J{^x4S37o~AKmpv@00)~ak@~QC4xOet#@XX_CvWRW3 zE(uhWc=E%-OdN2SCW1FGj&V}jtn7y#HSta<`<CnrEC@F~`e-&TR`Wtx6!?l6USZhT zUKc_VKJ<!3#tDdi@|SjbM*1xSgfNg969D<*a>fB_6!;Kkr2TMdE>o_r;SjH8Ywo3> zcA;F1npgDz$9fxZh^c=1Rmel%n$?khx8N=?70%qpRe?3b%@M`psoOKx{ZB?R4U>u- zwEj3)%>m%mzR)YdPx>C?j5<MwVG2Fk`Jhst3|mKH617rV4WxExhpAHy>QPUME&+@f z5DX6rQqs#N7Z~ksAF0NL*Gq{&O;crXzVxT*@&k%qOJ}i6*Lujn0mRBZkVfkexuC<2 zyRU5{c(py{Bv~aUxSkWJP}ytn2ShTGfQ7{CZiY4JU<^=a5(h$M-9Sr~lMmW%YC`Ct zKk5w8C0y~lJYIt=pbMT0Y$Q%hbOv{Pqp62SGB1rXU-m)OO&E?dicZi0D=!VABd=24 zwf@oExJGI9u`xQ#Gx_{LXb3Or*Pl61N46f^ZKLXR%}NtR{kR0$d-P8plc%X7)Xl`o zzf4z=dG}k+IF|F8xB{xHaqnMTAwa?3RMg0qNpHhUJ+|+*zXpc(eBdUh43lc_=Tm4? zVbEPUHnF*Z!iPkhCA4>2PyZE%R_kwQn@Qpe>F5Us-9V<l9`<hGT-BS26McKGCy<w5 zeSk4V^5P-hg$>%62|b2}<y^WJ7$U90r(9ajw;1&}U*49pIPE^TmLR^a22Om>kd5rn zo~bE*nN5$s@{<UtYOOM#>(j9F3j0a*5rE}O%wK3aQ3e&2e^35fBtrLCJQutFGHUXo z%lq#xm1hL$uD3ONr~1fq_E_USDQ?6BgeW=h;uIu{Dbc%d@v3t`1bo-=>8H;fosD4m z>30fRijy>DyOJj4kqZ^dr%Tkm3zS_nv&$rx*cDqse~qC#8sGy>tXn#M=~f`I-Y!DW zcRW|cMT`8ss^uAV63AMUdiC*<8vE-8mreoEkNOXG&|lgHts^-no~ZbIZj4G_MVtt! zyfJPD^0zq!jLe=th&8b@iXKynmxzJqp5%G^M#7ubkJ1I>MMib!Q~RvG(Z)Bk^)9e5 zd11Du*(MwZtvRgSP2HgbVmo64bZojONy}1DWaGF|Pz%#H%<|>HZp&{2rPl}lIR<cP z=470JN^ZdFxZXr;AzDac-N!jG4{{?&+DeDxIRKx^Lq~=Y)!-bt68Ns{_NwU<<0bM* z7lYP}`K)vk4Q6(r35l=>TQna|;KDY52$VJZ$0&10!;3mO4vy8&CUCpI#8kEt_^>_; zhHV=%ET+gu>aqpGS$$B{(U7>+*x+=XQ<ZbV+b!6}VS<~fpK~kHB|PWHy4eA+wlcJK zZ8vqh3Hjw(F<m>)e&1q!fMBaymJB{rdy6tf;Z+stfh+?&*&}&wn)bIc9EK8*r9Xfk z3kdES|Je`9{Bit;+p31Mj}K;(sWG{E_IHSX#akvG1s}uSxppgE>y<yMrDVT(y@Ngu z`JJnCgG%Tfw;i{<edLRpJ%9|~Z=D2vS|6J-j(%h1PC~i@R2%*EgD&GWvi5-h#|k+^ za2-<d@Pa-t(GLc-!7C1wd@QKSK@x>USEicVs<aIZM+AC$PHE{jz~iak?HX}=a}lP+ z_cjid*pRTpFDd^`EDX68_~!Qhm&&L8P{8mw*_;0L^#+Ey<n4X%-RaI@`ov~k^iMJD zb$u!0;Zx7o%9$4#`o|Gz+tpz#hnhL%fKH0OEYwe0<iEVZSgFAL6PrYD`KO@!?f9Bj UnwO8Pwm)P$XLj*`x;nt(UofD>?EnA( literal 0 HcmV?d00001 diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/wizban/NewRepository_composites.gif b/edu.kit.ipd.descartes.mm.applicationlevel.editor/icons/full/wizban/NewRepository_composites.gif new file mode 100644 index 0000000000000000000000000000000000000000..11a22401185f901c9ac8e31bc64f5067a70a6a6b GIT binary patch literal 2462 zcmd6m`8OMg8ivzyXM`x-QPZJfTAHHK&QR5AsWql$w2Ic!kg?USY8f{w=-48$rioY* zYbAC`Y)wT;A`FcZl_-%Sg2vLt=!_Znuek4d&imtcp6{IRvvaUDGxu`>TnBsx>}7X% zcWwR4+WKcYYhs8m9^%hQq#LX2Uo1ScEWNTVy|TKOy0fRU5j=zy)5_W}?*<%e<CkX( z$J)X%_5u0MK}9!1N^XV}yFA3XKE%0&KXZ>HxJTkWV~CzHrT62?ec~&9_o#p;k`T#N zK`Aw%sdeG$&m+?7qkpG7%5F?RH~)rh{SDKST1-O~(=toDvP!!#Bqnx`7lqY*xVnB^ z9gEN~P}ayU-(!&6!mX!|P`gHHtO<JmWFJq+9-HM)FO5$xPKcy}cgr)9HKBNALAEK8 zu3x^FedT_R<-M${-nm!3bFTTKZ65r)1;#EQ-_{@F_-g?ysL&-0=Ng7{i+JW9MR1S8 zd&Ceu_T<Za6Dob;D|{0w;7O!_<f>3qT?nc+I+GHc-58H<Mi#cGme5cov<y5Wlh~a} z?8+(c$*t(kt?0p!nOHItLwbQBzrd1T6xO`N)%TY-vCA3<%bNyCt=#H%ULAde(ltu$ z9&PS@-S%?4Yf#Y3dHa$l92}b+8W#^wNJgg?MkXcv>BTo9sYtRmEnb;j_%I_`U6Fq( zsb>)=ugd-%*fdz(!J~AK()uTQxo`Xbm|?%3<&Mwsg-fGT??)!*CuXFQ<qh$YeEGwt zrPZy$*R#Wu^L*jrn;EHKcKO}H2a#lTS}c>vKP`XwxU{<YVe`w{#^;5VP08~5(%RPQ z#^)`n&(?Iy=G?$!e^q;HX)&od9bc4Gh>gYM!Bf(R%`LUGw(dU0zYGj^bTb+%@z@^L z;Jeuw-oPIt?6EQ4#FSwEf4BC3SCBoUy<Y$*?E(~(wC$V9U#2P@HoO;Ta%{gVNY9aA zHl|ybrEU-`JafJXnW14ErR{+Ag=FYhBOsiXd4~eS^Bsgbxjz7H0H=~Un+QmmQq=Ow z6n}wJejR?OG-xaEmaBuc(YdJ$09W#@*i1s_dd(!>y~4II)1-K+HIQHLypuoY-ssK> z7A2^=LlK;fWzi5Voa)sXaV}{Gy2h%BJ}eHNphc4X(RTWzc12h4eHuV7DbW;(M5n8r zwykw44B}H<X_-fW*bsYCAcuGk?|~RrwMhI6q;*z27Mow^N_iF=;z_xW_Wb$8u~}Xx zEGl{1eCsZbeEam--e(_I-Z%fs+SNjzjX=CCjorEIVM!G*EL4_Hg<ZzIw{L@I99NTt zZ+mq~prVA69~Wj~fx|Qryn%6yliX%yKlHeXcS_l}WFMj+%=qZz+1MD(3uTeuD`t3w zVP|_?2ub+JD+U!SAo|H)+2tAOw+s+ML1s(<<g3dW2dEL^5zI*Y(b8OoTwlW>PR-Wb zOF`{Ixj1uP)dL*kZNMR>_~}=n4t;A@NBYfzyTDX9^8i-`)(kU87LTWF&)o1o8NoD6 zEOOBL{a`f*fLHrUuLM8sdxA6S1RaJc^l0aUN`2C89f^t5N@+Ea+Myk)PBo~{d|Gq~ zV8no6cu<g%UN*VFXm|TaH7=}PN(5?}DueT-KTVe(Q1n_li)FgjLk12YSMGx}T8GF5 z9d_J(Z5u(W?a3#}D$zmp9E3t;ufgvS$w)jF5~sTv+Mt6m$UKuU5F+aaTB@9U*mg@3 zLJ#>-XNWH0ir?q)8e{=o@LXUcablt~sN)+=Jv@qeX_Wb@52|j$aGX(ef(}@DX%HQG zmGZ9jPv*uoN~=$d(V?D6=LbT9d6B<d<v<<TdT_Ums?#+qO%(Ox5@_$yKX^=@rixHE z11tYJT}9?SXgT9p&THZdsIJDne{zKY1%FdfBVQ)H12gs5zSsT+7}E2Ro0L3Es(p}8 zp-qKCcjefG<^~EM5`LD@-fcboXDnK+zoBg=kuRj9A0BiAnf`LvyM=R2Zzfjs?YSNV zFW&k9V~XU(L%t6kv@sKU3=PY<bS*GMT7^%(w484->T$ljEoX7seQ+&ad_xVK@PQ#4 z*`YmGQ~Wxc7I)<*5m41yWj@!ZVdpjWv+832%a@qH&~%~<Dk}e;{Fg|C?y-0wcK><Q z<YkxlUtKEC3DR9}YxYj{kr(W-#(h%UhzST;a^A%$P!?UHcj4kS=YVkduH&=MUphJ) z!Sd7Z6|@v5Y07pbO{gOmDwI!`sCySEyJ%*YNiMM~wuJr~Lw7a62bx&7b^Ow-Kw`aJ zq@eG3u8NBm`FmB%GwLLewI=o2lOr|uHw-SF0-_)HAMBvNvJG5EaZWr{@%hpinYM~N z5nOq5+zjMza|#%dJ%12uVrLXJrW7X;1J6Cp^Y)E^H>)3|3&x9#>dvS1S$(68Z)WRV zU}5q?ZB4UHI1XBKSi4)gLkGlm#s=t^G*6P2rJ%^haigFXrf-<#%YogI-vLT*4E}u# z;L^-VKLM58gw=7qiP%E4ki>d`b7CIkhLg0F4##l-K9z@#3?r+-IdUcNJ=vXA)2GHu z<dZH2t?BbwX(k%XY=jAkun1c;ACBk3Hh{=XYxa+k=8lFJb#fdWtDjHcc7KkpY$fnv zeHIMcHdJVIk&o163xu=!sHmeMajUVx={lz<=Y+Leu#H0nw^F|3R-{RI&QEl+17K}s zXzki=>UI<A>-A!~cAovd#rgojR<$e%e5m#|Ws1V9D%1m626(bZ^4v7-Z>Kv9#iL4p z06h^9+%^8QAC&Rq_z!nf4QHPm%qCN#bMx%)690^|OgIWYhP`|JcAC~}|IC(>{pR%! z`Z&~guFefAA$Q$&-17F3FKYGx(tW>m67*?(YDz!)jg>nI<qA-3^w$r(jMvE82Lc=` z<P5=eNX5eo`oIJ~7}N%@I8gGbpehGN6c$~XYHq92HZU9!=;=A7rr7|Gr+l|-#O=*R znik*RI8<Uo!VbTp{5PR6_&Vb4o&B$rPy1y8!(wG```6bS80M0955V`PJBR5Ln{`n? zMYGrSrHn_<Jl`m1Tx94UN2YF9hq4@M=9B|EDf+SyKWUNw@&;q20`qrFBE9ABg6?<Y XYg(yZKC;^W;O(5*#RKZ<0E>SB0u9E( literal 0 HcmV?d00001 diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/plugin.properties b/edu.kit.ipd.descartes.mm.applicationlevel.editor/plugin.properties index 4ea831fb..ac069d6b 100644 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/plugin.properties +++ b/edu.kit.ipd.descartes.mm.applicationlevel.editor/plugin.properties @@ -87,3 +87,15 @@ _UI_Wizard_initial_object_description = Select a model object to create _UI_FileConflict_label = File Conflict _WARN_FileConflict = There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes? +_UI_Repository_compositesEditor_menu = &Repository_composites Editor +_UI_Repository_compositesModelWizard_label = Repository_composites Model +_UI_Repository_compositesModelWizard_description = Create a new Repository_composites model +_UI_Repository_compositesEditor_label = Repository_composites Model Editor +_UI_Repository_compositesEditorFilenameDefaultBase = My +_UI_Repository_compositesEditorFilenameExtensions = repository_composites +_UI_RepositoryCompositesEditor_menu = &RepositoryComposites Editor +_UI_RepositoryCompositesModelWizard_label = RepositoryComposites Model +_UI_RepositoryCompositesModelWizard_description = Create a new RepositoryComposites model +_UI_RepositoryCompositesEditor_label = RepositoryComposites Model Editor +_UI_RepositoryCompositesEditorFilenameDefaultBase = My +_UI_RepositoryCompositesEditorFilenameExtensions = repositorycomposites diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/applicationlevel/presentation/ApplicationlevelEditorPlugin.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/applicationlevel/presentation/ApplicationlevelEditorPlugin.java deleted file mode 100644 index a73b318f..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/applicationlevel/presentation/ApplicationlevelEditorPlugin.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.applicationlevel.presentation; - -import edu.kit.ipd.descartes.identifier.provider.IdentifierEditPlugin; - -import edu.kit.ipd.descartes.mm.core.provider.CoreEditPlugin; - -import edu.kit.ipd.descartes.mm.resourcelandscape.provider.ResourcelandscapeEditPlugin; - -import org.eclipse.emf.common.EMFPlugin; - -import org.eclipse.emf.common.ui.EclipseUIPlugin; - -import org.eclipse.emf.common.util.ResourceLocator; - -/** - * This is the central singleton for the Applicationlevel editor plugin. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public final class ApplicationlevelEditorPlugin extends EMFPlugin { - /** - * Keep track of the singleton. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final ApplicationlevelEditorPlugin INSTANCE = new ApplicationlevelEditorPlugin(); - - /** - * Keep track of the singleton. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static Implementation plugin; - - /** - * Create the instance. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ApplicationlevelEditorPlugin() { - super - (new ResourceLocator [] { - CoreEditPlugin.INSTANCE, - IdentifierEditPlugin.INSTANCE, - ResourcelandscapeEditPlugin.INSTANCE, - }); - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the singleton instance. - * @generated - */ - @Override - public ResourceLocator getPluginResourceLocator() { - return plugin; - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the singleton instance. - * @generated - */ - public static Implementation getPlugin() { - return plugin; - } - - /** - * The actual implementation of the Eclipse <b>Plugin</b>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static class Implementation extends EclipseUIPlugin { - /** - * Creates an instance. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Implementation() { - super(); - - // Remember the static instance. - // - plugin = this; - } - } - -} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsActionBarContributor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsActionBarContributor.java deleted file mode 100644 index bfd065ba..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsActionBarContributor.java +++ /dev/null @@ -1,426 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.functions.presentation; - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; - -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; - -import org.eclipse.emf.edit.ui.action.ControlAction; -import org.eclipse.emf.edit.ui.action.CreateChildAction; -import org.eclipse.emf.edit.ui.action.CreateSiblingAction; -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; -import org.eclipse.emf.edit.ui.action.LoadResourceAction; -import org.eclipse.emf.edit.ui.action.ValidateAction; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.action.SubContributionItem; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; - -/** - * This is the action bar contributor for the Functions model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class FunctionsActionBarContributor - extends EditingDomainActionBarContributor - implements ISelectionChangedListener { - /** - * This keeps track of the active editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IEditorPart activeEditorPart; - - /** - * This keeps track of the current selection provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelectionProvider selectionProvider; - - /** - * This action opens the Properties view. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IAction showPropertiesViewAction = - new Action(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { - @Override - public void run() { - try { - getPage().showView("org.eclipse.ui.views.PropertySheet"); - } - catch (PartInitException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - }; - - /** - * This action refreshes the viewer of the current editor if the editor - * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IAction refreshViewerAction = - new Action(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { - @Override - public boolean isEnabled() { - return activeEditorPart instanceof IViewerProvider; - } - - @Override - public void run() { - if (activeEditorPart instanceof IViewerProvider) { - Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); - if (viewer != null) { - viewer.refresh(); - } - } - } - }; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> createChildActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateChild actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IMenuManager createChildMenuManager; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> createSiblingActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateSibling actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IMenuManager createSiblingMenuManager; - - /** - * This creates an instance of the contributor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public FunctionsActionBarContributor() { - super(ADDITIONS_LAST_STYLE); - loadResourceAction = new LoadResourceAction(); - validateAction = new ValidateAction(); - controlAction = new ControlAction(); - } - - /** - * This adds Separators for editor additions to the tool bar. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void contributeToToolBar(IToolBarManager toolBarManager) { - toolBarManager.add(new Separator("functions-settings")); - toolBarManager.add(new Separator("functions-additions")); - } - - /** - * This adds to the menu bar a menu and some separators for editor additions, - * as well as the sub-menus for object creation items. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void contributeToMenu(IMenuManager menuManager) { - super.contributeToMenu(menuManager); - - IMenuManager submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_FunctionsEditor_menu"), "edu.kit.ipd.descartes.mm.functionsMenuID"); - menuManager.insertAfter("additions", submenuManager); - submenuManager.add(new Separator("settings")); - submenuManager.add(new Separator("actions")); - submenuManager.add(new Separator("additions")); - submenuManager.add(new Separator("additions-end")); - - // Prepare for CreateChild item addition or removal. - // - createChildMenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); - submenuManager.insertBefore("additions", createChildMenuManager); - - // Prepare for CreateSibling item addition or removal. - // - createSiblingMenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); - submenuManager.insertBefore("additions", createSiblingMenuManager); - - // Force an update because Eclipse hides empty menus now. - // - submenuManager.addMenuListener - (new IMenuListener() { - public void menuAboutToShow(IMenuManager menuManager) { - menuManager.updateAll(true); - } - }); - - addGlobalActions(submenuManager); - } - - /** - * When the active editor changes, this remembers the change and registers with it as a selection provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setActiveEditor(IEditorPart part) { - super.setActiveEditor(part); - activeEditorPart = part; - - // Switch to the new selection provider. - // - if (selectionProvider != null) { - selectionProvider.removeSelectionChangedListener(this); - } - if (part == null) { - selectionProvider = null; - } - else { - selectionProvider = part.getSite().getSelectionProvider(); - selectionProvider.addSelectionChangedListener(this); - - // Fake a selection changed event to update the menus. - // - if (selectionProvider.getSelection() != null) { - selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection())); - } - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, - * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings - * that can be added to the selected object and updating the menus accordingly. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void selectionChanged(SelectionChangedEvent event) { - // Remove any menu items for old selection. - // - if (createChildMenuManager != null) { - depopulateManager(createChildMenuManager, createChildActions); - } - if (createSiblingMenuManager != null) { - depopulateManager(createSiblingMenuManager, createSiblingActions); - } - - // Query the new selection for appropriate new child/sibling descriptors - // - Collection<?> newChildDescriptors = null; - Collection<?> newSiblingDescriptors = null; - - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) { - Object object = ((IStructuredSelection)selection).getFirstElement(); - - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); - - newChildDescriptors = domain.getNewChildDescriptors(object, null); - newSiblingDescriptors = domain.getNewChildDescriptors(null, object); - } - - // Generate actions for selection; populate and redraw the menus. - // - createChildActions = generateCreateChildActions(newChildDescriptors, selection); - createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection); - - if (createChildMenuManager != null) { - populateManager(createChildMenuManager, createChildActions, null); - createChildMenuManager.update(true); - } - if (createSiblingMenuManager != null) { - populateManager(createSiblingMenuManager, createSiblingActions, null); - createSiblingMenuManager.update(true); - } - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, - * and returns the collection of these actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) { - Collection<IAction> actions = new ArrayList<IAction>(); - if (descriptors != null) { - for (Object descriptor : descriptors) { - actions.add(new CreateChildAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>, - * and returns the collection of these actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) { - Collection<IAction> actions = new ArrayList<IAction>(); - if (descriptors != null) { - for (Object descriptor : descriptors) { - actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, - * by inserting them before the specified contribution item <code>contributionID</code>. - * If <code>contributionID</code> is <code>null</code>, they are simply added. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { - if (actions != null) { - for (IAction action : actions) { - if (contributionID != null) { - manager.insertBefore(contributionID, action); - } - else { - manager.add(action); - } - } - } - } - - /** - * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) { - if (actions != null) { - IContributionItem[] items = manager.getItems(); - for (int i = 0; i < items.length; i++) { - // Look into SubContributionItems - // - IContributionItem contributionItem = items[i]; - while (contributionItem instanceof SubContributionItem) { - contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); - } - - // Delete the ActionContributionItems with matching action. - // - if (contributionItem instanceof ActionContributionItem) { - IAction action = ((ActionContributionItem)contributionItem).getAction(); - if (actions.contains(action)) { - manager.remove(contributionItem); - } - } - } - } - } - - /** - * This populates the pop-up menu before it appears. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void menuAboutToShow(IMenuManager menuManager) { - super.menuAboutToShow(menuManager); - MenuManager submenuManager = null; - - submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); - populateManager(submenuManager, createChildActions, null); - menuManager.insertBefore("edit", submenuManager); - - submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); - populateManager(submenuManager, createSiblingActions, null); - menuManager.insertBefore("edit", submenuManager); - } - - /** - * This inserts global actions before the "additions-end" separator. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void addGlobalActions(IMenuManager menuManager) { - menuManager.insertAfter("additions-end", new Separator("ui-actions")); - menuManager.insertAfter("ui-actions", showPropertiesViewAction); - - refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); - menuManager.insertAfter("ui-actions", refreshViewerAction); - - super.addGlobalActions(menuManager); - } - - /** - * This ensures that a delete action will clean up all references to deleted objects. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected boolean removeAllReferencesOnDelete() { - return true; - } - -} \ No newline at end of file diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsEditor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsEditor.java deleted file mode 100644 index 2ffcc210..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsEditor.java +++ /dev/null @@ -1,1839 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.functions.presentation; - - -import java.io.IOException; -import java.io.InputStream; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EventObject; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; - -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.swt.SWT; - -import org.eclipse.swt.custom.CTabFolder; - -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.Transfer; - -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; - -import org.eclipse.swt.graphics.Point; - -import org.eclipse.swt.layout.FillLayout; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; - -import org.eclipse.ui.dialogs.SaveAsDialog; - -import org.eclipse.ui.ide.IGotoMarker; - -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.MultiPageEditorPart; - -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheet; -import org.eclipse.ui.views.properties.PropertySheetPage; - -import org.eclipse.emf.common.command.BasicCommandStack; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.common.command.CommandStackListener; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.common.ui.MarkerHelper; -import org.eclipse.emf.common.ui.ViewerPane; - -import org.eclipse.emf.common.ui.editor.ProblemEditorPart; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EValidator; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.emf.ecore.util.EcoreUtil; - -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; - -import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; - -import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; - -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; - -import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; - -import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; -import org.eclipse.emf.edit.ui.dnd.LocalTransfer; -import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; - -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider; - -import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper; -import org.eclipse.emf.edit.ui.util.EditUIUtil; - -import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; - -import edu.kit.ipd.descartes.mm.functions.provider.FunctionsItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.identifier.provider.IdentifierItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import edu.kit.ipd.descartes.mm.core.provider.CoreItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.parameterdependencies.provider.ParameterdependenciesItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.repository.provider.RepositoryItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.resourceconfiguration.provider.ResourceconfigurationItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.servicebehavior.provider.ServicebehaviorItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.system.provider.SystemItemProviderAdapterFactory; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - - -/** - * This is an example of a Functions model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class FunctionsEditor - extends MultiPageEditorPart - implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker { - /** - * This keeps track of the editing domain that is used to track all changes to the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected AdapterFactoryEditingDomain editingDomain; - - /** - * This is the one adapter factory used for providing views of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ComposedAdapterFactory adapterFactory; - - /** - * This is the content outline page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IContentOutlinePage contentOutlinePage; - - /** - * This is a kludge... - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IStatusLineManager contentOutlineStatusLineManager; - - /** - * This is the content outline page's viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer contentOutlineViewer; - - /** - * This is the property sheet page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected PropertySheetPage propertySheetPage; - - /** - * This is the viewer that shadows the selection in the content outline. - * The parent relation must be correctly defined for this to work. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer selectionViewer; - - /** - * This inverts the roll of parent and child in the content provider and show parents as a tree. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer parentViewer; - - /** - * This shows how a tree view works. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer treeViewer; - - /** - * This shows how a list view works. - * A list viewer doesn't support icons. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ListViewer listViewer; - - /** - * This shows how a table view works. - * A table can be used as a list with icons. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TableViewer tableViewer; - - /** - * This shows how a tree view with columns works. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer treeViewerWithColumns; - - /** - * This keeps track of the active viewer pane, in the book. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ViewerPane currentViewerPane; - - /** - * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Viewer currentViewer; - - /** - * This listens to which ever viewer is active. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelectionChangedListener selectionChangedListener; - - /** - * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); - - /** - * This keeps track of the selection of the editor as a whole. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelection editorSelection = StructuredSelection.EMPTY; - - /** - * The MarkerHelper is responsible for creating workspace resource markers presented - * in Eclipse's Problems View. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected MarkerHelper markerHelper = new EditUIMarkerHelper(); - - /** - * This listens for when the outline becomes active - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IPartListener partListener = - new IPartListener() { - public void partActivated(IWorkbenchPart p) { - if (p instanceof ContentOutline) { - if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) { - getActionBarContributor().setActiveEditor(FunctionsEditor.this); - - setCurrentViewer(contentOutlineViewer); - } - } - else if (p instanceof PropertySheet) { - if (((PropertySheet)p).getCurrentPage() == propertySheetPage) { - getActionBarContributor().setActiveEditor(FunctionsEditor.this); - handleActivate(); - } - } - else if (p == FunctionsEditor.this) { - handleActivate(); - } - } - public void partBroughtToTop(IWorkbenchPart p) { - // Ignore. - } - public void partClosed(IWorkbenchPart p) { - // Ignore. - } - public void partDeactivated(IWorkbenchPart p) { - // Ignore. - } - public void partOpened(IWorkbenchPart p) { - // Ignore. - } - }; - - /** - * Resources that have been removed since last activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> removedResources = new ArrayList<Resource>(); - - /** - * Resources that have been changed since last activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> changedResources = new ArrayList<Resource>(); - - /** - * Resources that have been saved. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> savedResources = new ArrayList<Resource>(); - - /** - * Map to store the diagnostic associated with a resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>(); - - /** - * Controls whether the problem indication should be updated. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean updateProblemIndication = true; - - /** - * Adapter used to update the problem indication when resources are demanded loaded. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EContentAdapter problemIndicationAdapter = - new EContentAdapter() { - @Override - public void notifyChanged(Notification notification) { - if (notification.getNotifier() instanceof Resource) { - switch (notification.getFeatureID(Resource.class)) { - case Resource.RESOURCE__IS_LOADED: - case Resource.RESOURCE__ERRORS: - case Resource.RESOURCE__WARNINGS: { - Resource resource = (Resource)notification.getNotifier(); - Diagnostic diagnostic = analyzeResourceProblems(resource, null); - if (diagnostic.getSeverity() != Diagnostic.OK) { - resourceToDiagnosticMap.put(resource, diagnostic); - } - else { - resourceToDiagnosticMap.remove(resource); - } - - if (updateProblemIndication) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - updateProblemIndication(); - } - }); - } - break; - } - } - } - else { - super.notifyChanged(notification); - } - } - - @Override - protected void setTarget(Resource target) { - basicSetTarget(target); - } - - @Override - protected void unsetTarget(Resource target) { - basicUnsetTarget(target); - } - }; - - /** - * This listens for workspace changes. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IResourceChangeListener resourceChangeListener = - new IResourceChangeListener() { - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - try { - class ResourceDeltaVisitor implements IResourceDeltaVisitor { - protected ResourceSet resourceSet = editingDomain.getResourceSet(); - protected Collection<Resource> changedResources = new ArrayList<Resource>(); - protected Collection<Resource> removedResources = new ArrayList<Resource>(); - - public boolean visit(IResourceDelta delta) { - if (delta.getResource().getType() == IResource.FILE) { - if (delta.getKind() == IResourceDelta.REMOVED || - delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) { - Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false); - if (resource != null) { - if (delta.getKind() == IResourceDelta.REMOVED) { - removedResources.add(resource); - } - else if (!savedResources.remove(resource)) { - changedResources.add(resource); - } - } - } - } - - return true; - } - - public Collection<Resource> getChangedResources() { - return changedResources; - } - - public Collection<Resource> getRemovedResources() { - return removedResources; - } - } - - final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - delta.accept(visitor); - - if (!visitor.getRemovedResources().isEmpty()) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - removedResources.addAll(visitor.getRemovedResources()); - if (!isDirty()) { - getSite().getPage().closeEditor(FunctionsEditor.this, false); - } - } - }); - } - - if (!visitor.getChangedResources().isEmpty()) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - changedResources.addAll(visitor.getChangedResources()); - if (getSite().getPage().getActiveEditor() == FunctionsEditor.this) { - handleActivate(); - } - } - }); - } - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - }; - - /** - * Handles activation of the editor or it's associated views. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void handleActivate() { - // Recompute the read only state. - // - if (editingDomain.getResourceToReadOnlyMap() != null) { - editingDomain.getResourceToReadOnlyMap().clear(); - - // Refresh any actions that may become enabled or disabled. - // - setSelection(getSelection()); - } - - if (!removedResources.isEmpty()) { - if (handleDirtyConflict()) { - getSite().getPage().closeEditor(FunctionsEditor.this, false); - } - else { - removedResources.clear(); - changedResources.clear(); - savedResources.clear(); - } - } - else if (!changedResources.isEmpty()) { - changedResources.removeAll(savedResources); - handleChangedResources(); - changedResources.clear(); - savedResources.clear(); - } - } - - /** - * Handles what to do with changed resources on activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void handleChangedResources() { - if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) { - if (isDirty()) { - changedResources.addAll(editingDomain.getResourceSet().getResources()); - } - editingDomain.getCommandStack().flush(); - - updateProblemIndication = false; - for (Resource resource : changedResources) { - if (resource.isLoaded()) { - resource.unload(); - try { - resource.load(Collections.EMPTY_MAP); - } - catch (IOException exception) { - if (!resourceToDiagnosticMap.containsKey(resource)) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - } - } - } - - if (AdapterFactoryEditingDomain.isStale(editorSelection)) { - setSelection(StructuredSelection.EMPTY); - } - - updateProblemIndication = true; - updateProblemIndication(); - } - } - - /** - * Updates the problems indication with the information described in the specified diagnostic. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void updateProblemIndication() { - if (updateProblemIndication) { - BasicDiagnostic diagnostic = - new BasicDiagnostic - (Diagnostic.OK, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - null, - new Object [] { editingDomain.getResourceSet() }); - for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) { - if (childDiagnostic.getSeverity() != Diagnostic.OK) { - diagnostic.add(childDiagnostic); - } - } - - int lastEditorPage = getPageCount() - 1; - if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) { - ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic); - if (diagnostic.getSeverity() != Diagnostic.OK) { - setActivePage(lastEditorPage); - } - } - else if (diagnostic.getSeverity() != Diagnostic.OK) { - ProblemEditorPart problemEditorPart = new ProblemEditorPart(); - problemEditorPart.setDiagnostic(diagnostic); - problemEditorPart.setMarkerHelper(markerHelper); - try { - addPage(++lastEditorPage, problemEditorPart, getEditorInput()); - setPageText(lastEditorPage, problemEditorPart.getPartName()); - setActivePage(lastEditorPage); - showTabs(); - } - catch (PartInitException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - - if (markerHelper.hasMarkers(editingDomain.getResourceSet())) { - markerHelper.deleteMarkers(editingDomain.getResourceSet()); - if (diagnostic.getSeverity() != Diagnostic.OK) { - try { - markerHelper.createMarkers(diagnostic); - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - } - } - } - - /** - * Shows a dialog that asks if conflicting changes should be discarded. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean handleDirtyConflict() { - return - MessageDialog.openQuestion - (getSite().getShell(), - getString("_UI_FileConflict_label"), - getString("_WARN_FileConflict")); - } - - /** - * This creates a model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public FunctionsEditor() { - super(); - initializeEditingDomain(); - } - - /** - * This sets up the editing domain for the model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void initializeEditingDomain() { - // Create an adapter factory that yields item providers. - // - adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - - adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new RepositoryItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ServicebehaviorItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new SystemItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ParameterdependenciesItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new FunctionsItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new CoreItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new IdentifierItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ResourceconfigurationItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ResourcetypeItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); - - // Create the command stack that will notify this editor as commands are executed. - // - BasicCommandStack commandStack = new BasicCommandStack(); - - // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. - // - commandStack.addCommandStackListener - (new CommandStackListener() { - public void commandStackChanged(final EventObject event) { - getContainer().getDisplay().asyncExec - (new Runnable() { - public void run() { - firePropertyChange(IEditorPart.PROP_DIRTY); - - // Try to select the affected objects. - // - Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); - if (mostRecentCommand != null) { - setSelectionToViewer(mostRecentCommand.getAffectedObjects()); - } - if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) { - propertySheetPage.refresh(); - } - } - }); - } - }); - - // Create the editing domain with a special command stack. - // - editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>()); - } - - /** - * This is here for the listener to be able to call it. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void firePropertyChange(int action) { - super.firePropertyChange(action); - } - - /** - * This sets the selection into whichever viewer is active. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSelectionToViewer(Collection<?> collection) { - final Collection<?> theSelection = collection; - // Make sure it's okay. - // - if (theSelection != null && !theSelection.isEmpty()) { - Runnable runnable = - new Runnable() { - public void run() { - // Try to select the items in the current content viewer of the editor. - // - if (currentViewer != null) { - currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); - } - } - }; - getSite().getShell().getDisplay().asyncExec(runnable); - } - } - - /** - * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. - * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} - * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EditingDomain getEditingDomain() { - return editingDomain; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object [] getElements(Object object) { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object [] getChildren(Object object) { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean hasChildren(Object object) { - Object parent = super.getParent(object); - return parent != null; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object getParent(Object object) { - return null; - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCurrentViewerPane(ViewerPane viewerPane) { - if (currentViewerPane != viewerPane) { - if (currentViewerPane != null) { - currentViewerPane.showFocus(false); - } - currentViewerPane = viewerPane; - } - setCurrentViewer(currentViewerPane.getViewer()); - } - - /** - * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, - * is the current one. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCurrentViewer(Viewer viewer) { - // If it is changing... - // - if (currentViewer != viewer) { - if (selectionChangedListener == null) { - // Create the listener on demand. - // - selectionChangedListener = - new ISelectionChangedListener() { - // This just notifies those things that are affected by the section. - // - public void selectionChanged(SelectionChangedEvent selectionChangedEvent) { - setSelection(selectionChangedEvent.getSelection()); - } - }; - } - - // Stop listening to the old one. - // - if (currentViewer != null) { - currentViewer.removeSelectionChangedListener(selectionChangedListener); - } - - // Start listening to the new one. - // - if (viewer != null) { - viewer.addSelectionChangedListener(selectionChangedListener); - } - - // Remember it. - // - currentViewer = viewer; - - // Set the editors selection based on the current viewer's selection. - // - setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); - } - } - - /** - * This returns the viewer as required by the {@link IViewerProvider} interface. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Viewer getViewer() { - return currentViewer; - } - - /** - * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createContextMenuFor(StructuredViewer viewer) { - MenuManager contextMenu = new MenuManager("#PopUp"); - contextMenu.add(new Separator("additions")); - contextMenu.setRemoveAllWhenShown(true); - contextMenu.addMenuListener(this); - Menu menu= contextMenu.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); - - int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; - Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() }; - viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); - viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); - } - - /** - * This is the method called to load a resource into the editing domain's resource set based on the editor's input. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createModel() { - URI resourceURI = EditUIUtil.getURI(getEditorInput()); - Exception exception = null; - Resource resource = null; - try { - // Load the resource through the editing domain. - // - resource = editingDomain.getResourceSet().getResource(resourceURI, true); - } - catch (Exception e) { - exception = e; - resource = editingDomain.getResourceSet().getResource(resourceURI, false); - } - - Diagnostic diagnostic = analyzeResourceProblems(resource, exception); - if (diagnostic.getSeverity() != Diagnostic.OK) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); - } - - /** - * Returns a diagnostic describing the errors and warnings listed in the resource - * and the specified exception (if any). - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) { - if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) { - BasicDiagnostic basicDiagnostic = - new BasicDiagnostic - (Diagnostic.ERROR, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object [] { exception == null ? (Object)resource : exception }); - basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); - return basicDiagnostic; - } - else if (exception != null) { - return - new BasicDiagnostic - (Diagnostic.ERROR, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object[] { exception }); - } - else { - return Diagnostic.OK_INSTANCE; - } - } - - /** - * This is the method used by the framework to install your own controls. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void createPages() { - // Creates the model from the editor input - // - createModel(); - - // Only creates the other pages if there is something that can be edited - // - if (!getEditingDomain().getResourceSet().getResources().isEmpty()) { - // Create a page for the selection tree view. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), FunctionsEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - Tree tree = new Tree(composite, SWT.MULTI); - TreeViewer newTreeViewer = new TreeViewer(tree); - return newTreeViewer; - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - selectionViewer = (TreeViewer)viewerPane.getViewer(); - selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - - selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - selectionViewer.setInput(editingDomain.getResourceSet()); - selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - viewerPane.setTitle(editingDomain.getResourceSet()); - - new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); - - createContextMenuFor(selectionViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_SelectionPage_label")); - } - - // Create a page for the parent tree view. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), FunctionsEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - Tree tree = new Tree(composite, SWT.MULTI); - TreeViewer newTreeViewer = new TreeViewer(tree); - return newTreeViewer; - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - parentViewer = (TreeViewer)viewerPane.getViewer(); - parentViewer.setAutoExpandLevel(30); - parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory)); - parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(parentViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_ParentPage_label")); - } - - // This is the page for the list viewer - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), FunctionsEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new ListViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - listViewer = (ListViewer)viewerPane.getViewer(); - listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(listViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_ListPage_label")); - } - - // This is the page for the tree viewer - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), FunctionsEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TreeViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - treeViewer = (TreeViewer)viewerPane.getViewer(); - treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); - - createContextMenuFor(treeViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TreePage_label")); - } - - // This is the page for the table viewer. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), FunctionsEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TableViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - tableViewer = (TableViewer)viewerPane.getViewer(); - - Table table = tableViewer.getTable(); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - TableColumn objectColumn = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(3, 100, true)); - objectColumn.setText(getString("_UI_ObjectColumn_label")); - objectColumn.setResizable(true); - - TableColumn selfColumn = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(2, 100, true)); - selfColumn.setText(getString("_UI_SelfColumn_label")); - selfColumn.setResizable(true); - - tableViewer.setColumnProperties(new String [] {"a", "b"}); - tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(tableViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TablePage_label")); - } - - // This is the page for the table tree viewer. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), FunctionsEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TreeViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - treeViewerWithColumns = (TreeViewer)viewerPane.getViewer(); - - Tree tree = treeViewerWithColumns.getTree(); - tree.setLayoutData(new FillLayout()); - tree.setHeaderVisible(true); - tree.setLinesVisible(true); - - TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE); - objectColumn.setText(getString("_UI_ObjectColumn_label")); - objectColumn.setResizable(true); - objectColumn.setWidth(250); - - TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE); - selfColumn.setText(getString("_UI_SelfColumn_label")); - selfColumn.setResizable(true); - selfColumn.setWidth(200); - - treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"}); - treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(treeViewerWithColumns); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); - } - - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - setActivePage(0); - } - }); - } - - // Ensures that this editor will only display the page's tab - // area if there are more than one page - // - getContainer().addControlListener - (new ControlAdapter() { - boolean guard = false; - @Override - public void controlResized(ControlEvent event) { - if (!guard) { - guard = true; - hideTabs(); - guard = false; - } - } - }); - - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - updateProblemIndication(); - } - }); - } - - /** - * If there is just one page in the multi-page editor part, - * this hides the single tab at the bottom. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void hideTabs() { - if (getPageCount() <= 1) { - setPageText(0, ""); - if (getContainer() instanceof CTabFolder) { - ((CTabFolder)getContainer()).setTabHeight(1); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y + 6); - } - } - } - - /** - * If there is more than one page in the multi-page editor part, - * this shows the tabs at the bottom. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void showTabs() { - if (getPageCount() > 1) { - setPageText(0, getString("_UI_SelectionPage_label")); - if (getContainer() instanceof CTabFolder) { - ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y - 6); - } - } - } - - /** - * This is used to track the active viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void pageChange(int pageIndex) { - super.pageChange(pageIndex); - - if (contentOutlinePage != null) { - handleContentOutlineSelection(contentOutlinePage.getSelection()); - } - } - - /** - * This is how the framework determines which interfaces we implement. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class key) { - if (key.equals(IContentOutlinePage.class)) { - return showOutlineView() ? getContentOutlinePage() : null; - } - else if (key.equals(IPropertySheetPage.class)) { - return getPropertySheetPage(); - } - else if (key.equals(IGotoMarker.class)) { - return this; - } - else { - return super.getAdapter(key); - } - } - - /** - * This accesses a cached version of the content outliner. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IContentOutlinePage getContentOutlinePage() { - if (contentOutlinePage == null) { - // The content outline is just a tree. - // - class MyContentOutlinePage extends ContentOutlinePage { - @Override - public void createControl(Composite parent) { - super.createControl(parent); - contentOutlineViewer = getTreeViewer(); - contentOutlineViewer.addSelectionChangedListener(this); - - // Set up the tree viewer. - // - contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - contentOutlineViewer.setInput(editingDomain.getResourceSet()); - - // Make sure our popups work. - // - createContextMenuFor(contentOutlineViewer); - - if (!editingDomain.getResourceSet().getResources().isEmpty()) { - // Select the root object in the view. - // - contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - } - } - - @Override - public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { - super.makeContributions(menuManager, toolBarManager, statusLineManager); - contentOutlineStatusLineManager = statusLineManager; - } - - @Override - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - } - - contentOutlinePage = new MyContentOutlinePage(); - - // Listen to selection so that we can handle it is a special way. - // - contentOutlinePage.addSelectionChangedListener - (new ISelectionChangedListener() { - // This ensures that we handle selections correctly. - // - public void selectionChanged(SelectionChangedEvent event) { - handleContentOutlineSelection(event.getSelection()); - } - }); - } - - return contentOutlinePage; - } - - /** - * This accesses a cached version of the property sheet. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IPropertySheetPage getPropertySheetPage() { - if (propertySheetPage == null) { - propertySheetPage = - new ExtendedPropertySheetPage(editingDomain) { - @Override - public void setSelectionToViewer(List<?> selection) { - FunctionsEditor.this.setSelectionToViewer(selection); - FunctionsEditor.this.setFocus(); - } - - @Override - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - }; - propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); - } - - return propertySheetPage; - } - - /** - * This deals with how we want selection in the outliner to affect the other views. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void handleContentOutlineSelection(ISelection selection) { - if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { - Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator(); - if (selectedElements.hasNext()) { - // Get the first selected element. - // - Object selectedElement = selectedElements.next(); - - // If it's the selection viewer, then we want it to select the same selection as this selection. - // - if (currentViewerPane.getViewer() == selectionViewer) { - ArrayList<Object> selectionList = new ArrayList<Object>(); - selectionList.add(selectedElement); - while (selectedElements.hasNext()) { - selectionList.add(selectedElements.next()); - } - - // Set the selection to the widget. - // - selectionViewer.setSelection(new StructuredSelection(selectionList)); - } - else { - // Set the input to the widget. - // - if (currentViewerPane.getViewer().getInput() != selectedElement) { - currentViewerPane.getViewer().setInput(selectedElement); - currentViewerPane.setTitle(selectedElement); - } - } - } - } - } - - /** - * This is for implementing {@link IEditorPart} and simply tests the command stack. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean isDirty() { - return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded(); - } - - /** - * This is for implementing {@link IEditorPart} and simply saves the model file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void doSave(IProgressMonitor progressMonitor) { - // Save only resources that have actually changed. - // - final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); - saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); - - // Do the work within an operation because this is a long running activity that modifies the workbench. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - // This is the method that gets invoked when the operation runs. - // - @Override - public void execute(IProgressMonitor monitor) { - // Save the resources to the file system. - // - boolean first = true; - for (Resource resource : editingDomain.getResourceSet().getResources()) { - if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { - try { - long timeStamp = resource.getTimeStamp(); - resource.save(saveOptions); - if (resource.getTimeStamp() != timeStamp) { - savedResources.add(resource); - } - } - catch (Exception exception) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - first = false; - } - } - } - }; - - updateProblemIndication = false; - try { - // This runs the options, and shows progress. - // - new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); - - // Refresh the necessary state. - // - ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); - firePropertyChange(IEditorPart.PROP_DIRTY); - } - catch (Exception exception) { - // Something went wrong that shouldn't. - // - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - updateProblemIndication = true; - updateProblemIndication(); - } - - /** - * This returns whether something has been persisted to the URI of the specified resource. - * The implementation uses the URI converter from the editor's resource set to try to open an input stream. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean isPersisted(Resource resource) { - boolean result = false; - try { - InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); - if (stream != null) { - result = true; - stream.close(); - } - } - catch (IOException e) { - // Ignore - } - return result; - } - - /** - * This always returns true because it is not currently supported. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean isSaveAsAllowed() { - return true; - } - - /** - * This also changes the editor's input. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void doSaveAs() { - SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); - saveAsDialog.open(); - IPath path = saveAsDialog.getResult(); - if (path != null) { - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - if (file != null) { - doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void doSaveAs(URI uri, IEditorInput editorInput) { - (editingDomain.getResourceSet().getResources().get(0)).setURI(uri); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - IProgressMonitor progressMonitor = - getActionBars().getStatusLineManager() != null ? - getActionBars().getStatusLineManager().getProgressMonitor() : - new NullProgressMonitor(); - doSave(progressMonitor); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void gotoMarker(IMarker marker) { - try { - if (marker.getType().equals(EValidator.MARKER)) { - String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null); - if (uriAttribute != null) { - URI uri = URI.createURI(uriAttribute); - EObject eObject = editingDomain.getResourceSet().getEObject(uri, true); - if (eObject != null) { - setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject))); - } - } - } - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - - /** - * This is called during startup. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void init(IEditorSite site, IEditorInput editorInput) { - setSite(site); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - site.setSelectionProvider(this); - site.getPage().addPartListener(partListener); - ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setFocus() { - if (currentViewerPane != null) { - currentViewerPane.setFocus(); - } - else { - getControl(getActivePage()).setFocus(); - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ISelection getSelection() { - return editorSelection; - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. - * Calling this result will notify the listeners. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSelection(ISelection selection) { - editorSelection = selection; - - for (ISelectionChangedListener listener : selectionChangedListeners) { - listener.selectionChanged(new SelectionChangedEvent(this, selection)); - } - setStatusLineManager(selection); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setStatusLineManager(ISelection selection) { - IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? - contentOutlineStatusLineManager : getActionBars().getStatusLineManager(); - - if (statusLineManager != null) { - if (selection instanceof IStructuredSelection) { - Collection<?> collection = ((IStructuredSelection)selection).toList(); - switch (collection.size()) { - case 0: { - statusLineManager.setMessage(getString("_UI_NoObjectSelected")); - break; - } - case 1: { - String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next()); - statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); - break; - } - default: { - statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size()))); - break; - } - } - } - else { - statusLineManager.setMessage(""); - } - } - } - - /** - * This looks up a string in the plugin's plugin.properties file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static String getString(String key) { - return ApplicationlevelEditorPlugin.INSTANCE.getString(key); - } - - /** - * This looks up a string in plugin.properties, making a substitution. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static String getString(String key, Object s1) { - return ApplicationlevelEditorPlugin.INSTANCE.getString(key, new Object [] { s1 }); - } - - /** - * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void menuAboutToShow(IMenuManager menuManager) { - ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EditingDomainActionBarContributor getActionBarContributor() { - return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IActionBars getActionBars() { - return getActionBarContributor().getActionBars(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public AdapterFactory getAdapterFactory() { - return adapterFactory; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void dispose() { - updateProblemIndication = false; - - ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); - - getSite().getPage().removePartListener(partListener); - - adapterFactory.dispose(); - - if (getActionBarContributor().getActiveEditor() == this) { - getActionBarContributor().setActiveEditor(null); - } - - if (propertySheetPage != null) { - propertySheetPage.dispose(); - } - - if (contentOutlinePage != null) { - contentOutlinePage.dispose(); - } - - super.dispose(); - } - - /** - * Returns whether the outline view should be presented to the user. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean showOutlineView() { - return true; - } -} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsModelWizard.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsModelWizard.java deleted file mode 100644 index dbabd5fb..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/functions/presentation/FunctionsModelWizard.java +++ /dev/null @@ -1,630 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.functions.presentation; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.StringTokenizer; - -import org.eclipse.emf.common.CommonPlugin; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.jface.dialogs.MessageDialog; - -import org.eclipse.jface.viewers.IStructuredSelection; - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; - -import org.eclipse.swt.SWT; - -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.ModifyEvent; - -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; - -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; - -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; - -import edu.kit.ipd.descartes.mm.functions.FunctionsFactory; -import edu.kit.ipd.descartes.mm.functions.FunctionsPackage; -import edu.kit.ipd.descartes.mm.applicationlevel.provider.ApplicationlevelEditPlugin; - - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import org.eclipse.core.runtime.Path; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; - -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; - - -/** - * This is a simple wizard for creating a new model file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class FunctionsModelWizard extends Wizard implements INewWizard { - /** - * The supported extensions for created files. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final List<String> FILE_EXTENSIONS = - Collections.unmodifiableList(Arrays.asList(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_FunctionsEditorFilenameExtensions").split("\\s*,\\s*"))); - - /** - * A formatted list of supported file extensions, suitable for display. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String FORMATTED_FILE_EXTENSIONS = - ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_FunctionsEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); - - /** - * This caches an instance of the model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected FunctionsPackage functionsPackage = FunctionsPackage.eINSTANCE; - - /** - * This caches an instance of the model factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected FunctionsFactory functionsFactory = functionsPackage.getFunctionsFactory(); - - /** - * This is the file creation page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected FunctionsModelWizardNewFileCreationPage newFileCreationPage; - - /** - * This is the initial object creation page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected FunctionsModelWizardInitialObjectCreationPage initialObjectCreationPage; - - /** - * Remember the selection during initialization for populating the default container. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IStructuredSelection selection; - - /** - * Remember the workbench during initialization. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IWorkbench workbench; - - /** - * Caches the names of the types that can be created as the root object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected List<String> initialObjectNames; - - /** - * This just records the information. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.workbench = workbench; - this.selection = selection; - setWindowTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_label")); - setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(ApplicationlevelEditorPlugin.INSTANCE.getImage("full/wizban/NewFunctions"))); - } - - /** - * Returns the names of the types that can be created as the root object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<String> getInitialObjectNames() { - if (initialObjectNames == null) { - initialObjectNames = new ArrayList<String>(); - for (EClassifier eClassifier : functionsPackage.getEClassifiers()) { - if (eClassifier instanceof EClass) { - EClass eClass = (EClass)eClassifier; - if (!eClass.isAbstract()) { - initialObjectNames.add(eClass.getName()); - } - } - } - Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator()); - } - return initialObjectNames; - } - - /** - * Create a new model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EObject createInitialModel() { - EClass eClass = (EClass)functionsPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName()); - EObject rootObject = functionsFactory.create(eClass); - return rootObject; - } - - /** - * Do the work after everything is specified. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean performFinish() { - try { - // Remember the file. - // - final IFile modelFile = getModelFile(); - - // Do the work within an operation. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - @Override - protected void execute(IProgressMonitor progressMonitor) { - try { - // Create a resource set - // - ResourceSet resourceSet = new ResourceSetImpl(); - - // Get the URI of the model file. - // - URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true); - - // Create a resource for this file. - // - Resource resource = resourceSet.createResource(fileURI); - - // Add the initial model object to the contents. - // - EObject rootObject = createInitialModel(); - if (rootObject != null) { - resource.getContents().add(rootObject); - } - - // Save the contents of the resource to the file system. - // - Map<Object, Object> options = new HashMap<Object, Object>(); - options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding()); - resource.save(options); - } - catch (Exception exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - finally { - progressMonitor.done(); - } - } - }; - - getContainer().run(false, false, operation); - - // Select the new file resource in the current view. - // - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IWorkbenchPage page = workbenchWindow.getActivePage(); - final IWorkbenchPart activePart = page.getActivePart(); - if (activePart instanceof ISetSelectionTarget) { - final ISelection targetSelection = new StructuredSelection(modelFile); - getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - ((ISetSelectionTarget)activePart).selectReveal(targetSelection); - } - }); - } - - // Open an editor on the new file. - // - try { - page.openEditor - (new FileEditorInput(modelFile), - workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId()); - } - catch (PartInitException exception) { - MessageDialog.openError(workbenchWindow.getShell(), ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); - return false; - } - - return true; - } - catch (Exception exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - return false; - } - } - - /** - * This is the one page of the wizard. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class FunctionsModelWizardNewFileCreationPage extends WizardNewFileCreationPage { - /** - * Pass in the selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public FunctionsModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) { - super(pageId, selection); - } - - /** - * The framework calls this to see if the file is correct. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected boolean validatePage() { - if (super.validatePage()) { - String extension = new Path(getFileName()).getFileExtension(); - if (extension == null || !FILE_EXTENSIONS.contains(extension)) { - String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; - setErrorMessage(ApplicationlevelEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS })); - return false; - } - return true; - } - return false; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IFile getModelFile() { - return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName())); - } - } - - /** - * This is the page where the type of object to create is selected. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class FunctionsModelWizardInitialObjectCreationPage extends WizardPage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Combo initialObjectField; - - /** - * @generated - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - */ - protected List<String> encodings; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Combo encodingField; - - /** - * Pass in the selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public FunctionsModelWizardInitialObjectCreationPage(String pageId) { - super(pageId); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); { - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.verticalSpacing = 12; - composite.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - } - - Label containerLabel = new Label(composite, SWT.LEFT); - { - containerLabel.setText(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ModelObject")); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - containerLabel.setLayoutData(data); - } - - initialObjectField = new Combo(composite, SWT.BORDER); - { - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - initialObjectField.setLayoutData(data); - } - - for (String objectName : getInitialObjectNames()) { - initialObjectField.add(getLabel(objectName)); - } - - if (initialObjectField.getItemCount() == 1) { - initialObjectField.select(0); - } - initialObjectField.addModifyListener(validator); - - Label encodingLabel = new Label(composite, SWT.LEFT); - { - encodingLabel.setText(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_XMLEncoding")); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - encodingLabel.setLayoutData(data); - } - encodingField = new Combo(composite, SWT.BORDER); - { - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - encodingField.setLayoutData(data); - } - - for (String encoding : getEncodings()) { - encodingField.add(encoding); - } - - encodingField.select(0); - encodingField.addModifyListener(validator); - - setPageComplete(validatePage()); - setControl(composite); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ModifyListener validator = - new ModifyListener() { - public void modifyText(ModifyEvent e) { - setPageComplete(validatePage()); - } - }; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean validatePage() { - return getInitialObjectName() != null && getEncodings().contains(encodingField.getText()); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - if (initialObjectField.getItemCount() == 1) { - initialObjectField.clearSelection(); - encodingField.setFocus(); - } - else { - encodingField.clearSelection(); - initialObjectField.setFocus(); - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getInitialObjectName() { - String label = initialObjectField.getText(); - - for (String name : getInitialObjectNames()) { - if (getLabel(name).equals(label)) { - return name; - } - } - return null; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getEncoding() { - return encodingField.getText(); - } - - /** - * Returns the label for the specified type name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected String getLabel(String typeName) { - try { - return ApplicationlevelEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); - } - catch(MissingResourceException mre) { - ApplicationlevelEditorPlugin.INSTANCE.log(mre); - } - return typeName; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<String> getEncodings() { - if (encodings == null) { - encodings = new ArrayList<String>(); - for (StringTokenizer stringTokenizer = new StringTokenizer(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) { - encodings.add(stringTokenizer.nextToken()); - } - } - return encodings; - } - } - - /** - * The framework calls this to create the contents of the wizard. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void addPages() { - // Create a page, set the title, and the initial model file name. - // - newFileCreationPage = new FunctionsModelWizardNewFileCreationPage("Whatever", selection); - newFileCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_FunctionsModelWizard_label")); - newFileCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_FunctionsModelWizard_description")); - newFileCreationPage.setFileName(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_FunctionsEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); - addPage(newFileCreationPage); - - // Try and get the resource selection to determine a current directory for the file dialog. - // - if (selection != null && !selection.isEmpty()) { - // Get the resource... - // - Object selectedElement = selection.iterator().next(); - if (selectedElement instanceof IResource) { - // Get the resource parent, if its a file. - // - IResource selectedResource = (IResource)selectedElement; - if (selectedResource.getType() == IResource.FILE) { - selectedResource = selectedResource.getParent(); - } - - // This gives us a directory... - // - if (selectedResource instanceof IFolder || selectedResource instanceof IProject) { - // Set this for the container. - // - newFileCreationPage.setContainerFullPath(selectedResource.getFullPath()); - - // Make up a unique new name here. - // - String defaultModelBaseFilename = ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_FunctionsEditorFilenameDefaultBase"); - String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0); - String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; - for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) { - modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; - } - newFileCreationPage.setFileName(modelFilename); - } - } - } - initialObjectCreationPage = new FunctionsModelWizardInitialObjectCreationPage("Whatever2"); - initialObjectCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_FunctionsModelWizard_label")); - initialObjectCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description")); - addPage(initialObjectCreationPage); - } - - /** - * Get the file from the page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IFile getModelFile() { - return newFileCreationPage.getModelFile(); - } - -} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesActionBarContributor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesActionBarContributor.java deleted file mode 100644 index 859be446..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesActionBarContributor.java +++ /dev/null @@ -1,426 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.parameterdependencies.presentation; - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; - -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; - -import org.eclipse.emf.edit.ui.action.ControlAction; -import org.eclipse.emf.edit.ui.action.CreateChildAction; -import org.eclipse.emf.edit.ui.action.CreateSiblingAction; -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; -import org.eclipse.emf.edit.ui.action.LoadResourceAction; -import org.eclipse.emf.edit.ui.action.ValidateAction; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.action.SubContributionItem; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; - -/** - * This is the action bar contributor for the Parameterdependencies model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class ParameterdependenciesActionBarContributor - extends EditingDomainActionBarContributor - implements ISelectionChangedListener { - /** - * This keeps track of the active editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IEditorPart activeEditorPart; - - /** - * This keeps track of the current selection provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelectionProvider selectionProvider; - - /** - * This action opens the Properties view. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IAction showPropertiesViewAction = - new Action(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { - @Override - public void run() { - try { - getPage().showView("org.eclipse.ui.views.PropertySheet"); - } - catch (PartInitException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - }; - - /** - * This action refreshes the viewer of the current editor if the editor - * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IAction refreshViewerAction = - new Action(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { - @Override - public boolean isEnabled() { - return activeEditorPart instanceof IViewerProvider; - } - - @Override - public void run() { - if (activeEditorPart instanceof IViewerProvider) { - Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); - if (viewer != null) { - viewer.refresh(); - } - } - } - }; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> createChildActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateChild actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IMenuManager createChildMenuManager; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> createSiblingActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateSibling actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IMenuManager createSiblingMenuManager; - - /** - * This creates an instance of the contributor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ParameterdependenciesActionBarContributor() { - super(ADDITIONS_LAST_STYLE); - loadResourceAction = new LoadResourceAction(); - validateAction = new ValidateAction(); - controlAction = new ControlAction(); - } - - /** - * This adds Separators for editor additions to the tool bar. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void contributeToToolBar(IToolBarManager toolBarManager) { - toolBarManager.add(new Separator("parameterdependencies-settings")); - toolBarManager.add(new Separator("parameterdependencies-additions")); - } - - /** - * This adds to the menu bar a menu and some separators for editor additions, - * as well as the sub-menus for object creation items. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void contributeToMenu(IMenuManager menuManager) { - super.contributeToMenu(menuManager); - - IMenuManager submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ParameterdependenciesEditor_menu"), "edu.kit.ipd.descartes.mm.parameterdependenciesMenuID"); - menuManager.insertAfter("additions", submenuManager); - submenuManager.add(new Separator("settings")); - submenuManager.add(new Separator("actions")); - submenuManager.add(new Separator("additions")); - submenuManager.add(new Separator("additions-end")); - - // Prepare for CreateChild item addition or removal. - // - createChildMenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); - submenuManager.insertBefore("additions", createChildMenuManager); - - // Prepare for CreateSibling item addition or removal. - // - createSiblingMenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); - submenuManager.insertBefore("additions", createSiblingMenuManager); - - // Force an update because Eclipse hides empty menus now. - // - submenuManager.addMenuListener - (new IMenuListener() { - public void menuAboutToShow(IMenuManager menuManager) { - menuManager.updateAll(true); - } - }); - - addGlobalActions(submenuManager); - } - - /** - * When the active editor changes, this remembers the change and registers with it as a selection provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setActiveEditor(IEditorPart part) { - super.setActiveEditor(part); - activeEditorPart = part; - - // Switch to the new selection provider. - // - if (selectionProvider != null) { - selectionProvider.removeSelectionChangedListener(this); - } - if (part == null) { - selectionProvider = null; - } - else { - selectionProvider = part.getSite().getSelectionProvider(); - selectionProvider.addSelectionChangedListener(this); - - // Fake a selection changed event to update the menus. - // - if (selectionProvider.getSelection() != null) { - selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection())); - } - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, - * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings - * that can be added to the selected object and updating the menus accordingly. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void selectionChanged(SelectionChangedEvent event) { - // Remove any menu items for old selection. - // - if (createChildMenuManager != null) { - depopulateManager(createChildMenuManager, createChildActions); - } - if (createSiblingMenuManager != null) { - depopulateManager(createSiblingMenuManager, createSiblingActions); - } - - // Query the new selection for appropriate new child/sibling descriptors - // - Collection<?> newChildDescriptors = null; - Collection<?> newSiblingDescriptors = null; - - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) { - Object object = ((IStructuredSelection)selection).getFirstElement(); - - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); - - newChildDescriptors = domain.getNewChildDescriptors(object, null); - newSiblingDescriptors = domain.getNewChildDescriptors(null, object); - } - - // Generate actions for selection; populate and redraw the menus. - // - createChildActions = generateCreateChildActions(newChildDescriptors, selection); - createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection); - - if (createChildMenuManager != null) { - populateManager(createChildMenuManager, createChildActions, null); - createChildMenuManager.update(true); - } - if (createSiblingMenuManager != null) { - populateManager(createSiblingMenuManager, createSiblingActions, null); - createSiblingMenuManager.update(true); - } - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, - * and returns the collection of these actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) { - Collection<IAction> actions = new ArrayList<IAction>(); - if (descriptors != null) { - for (Object descriptor : descriptors) { - actions.add(new CreateChildAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>, - * and returns the collection of these actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) { - Collection<IAction> actions = new ArrayList<IAction>(); - if (descriptors != null) { - for (Object descriptor : descriptors) { - actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, - * by inserting them before the specified contribution item <code>contributionID</code>. - * If <code>contributionID</code> is <code>null</code>, they are simply added. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { - if (actions != null) { - for (IAction action : actions) { - if (contributionID != null) { - manager.insertBefore(contributionID, action); - } - else { - manager.add(action); - } - } - } - } - - /** - * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) { - if (actions != null) { - IContributionItem[] items = manager.getItems(); - for (int i = 0; i < items.length; i++) { - // Look into SubContributionItems - // - IContributionItem contributionItem = items[i]; - while (contributionItem instanceof SubContributionItem) { - contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); - } - - // Delete the ActionContributionItems with matching action. - // - if (contributionItem instanceof ActionContributionItem) { - IAction action = ((ActionContributionItem)contributionItem).getAction(); - if (actions.contains(action)) { - manager.remove(contributionItem); - } - } - } - } - } - - /** - * This populates the pop-up menu before it appears. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void menuAboutToShow(IMenuManager menuManager) { - super.menuAboutToShow(menuManager); - MenuManager submenuManager = null; - - submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); - populateManager(submenuManager, createChildActions, null); - menuManager.insertBefore("edit", submenuManager); - - submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); - populateManager(submenuManager, createSiblingActions, null); - menuManager.insertBefore("edit", submenuManager); - } - - /** - * This inserts global actions before the "additions-end" separator. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void addGlobalActions(IMenuManager menuManager) { - menuManager.insertAfter("additions-end", new Separator("ui-actions")); - menuManager.insertAfter("ui-actions", showPropertiesViewAction); - - refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); - menuManager.insertAfter("ui-actions", refreshViewerAction); - - super.addGlobalActions(menuManager); - } - - /** - * This ensures that a delete action will clean up all references to deleted objects. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected boolean removeAllReferencesOnDelete() { - return true; - } - -} \ No newline at end of file diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesEditor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesEditor.java deleted file mode 100644 index 3a4a56a8..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesEditor.java +++ /dev/null @@ -1,1839 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.parameterdependencies.presentation; - - -import java.io.IOException; -import java.io.InputStream; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EventObject; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; - -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.swt.SWT; - -import org.eclipse.swt.custom.CTabFolder; - -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.Transfer; - -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; - -import org.eclipse.swt.graphics.Point; - -import org.eclipse.swt.layout.FillLayout; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; - -import org.eclipse.ui.dialogs.SaveAsDialog; - -import org.eclipse.ui.ide.IGotoMarker; - -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.MultiPageEditorPart; - -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheet; -import org.eclipse.ui.views.properties.PropertySheetPage; - -import org.eclipse.emf.common.command.BasicCommandStack; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.common.command.CommandStackListener; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.common.ui.MarkerHelper; -import org.eclipse.emf.common.ui.ViewerPane; - -import org.eclipse.emf.common.ui.editor.ProblemEditorPart; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EValidator; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.emf.ecore.util.EcoreUtil; - -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; - -import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; - -import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; - -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; - -import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; - -import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; -import org.eclipse.emf.edit.ui.dnd.LocalTransfer; -import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; - -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider; - -import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper; -import org.eclipse.emf.edit.ui.util.EditUIUtil; - -import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; - -import edu.kit.ipd.descartes.mm.parameterdependencies.provider.ParameterdependenciesItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.identifier.provider.IdentifierItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import edu.kit.ipd.descartes.mm.core.provider.CoreItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.functions.provider.FunctionsItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.repository.provider.RepositoryItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.resourceconfiguration.provider.ResourceconfigurationItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.servicebehavior.provider.ServicebehaviorItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.system.provider.SystemItemProviderAdapterFactory; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - - -/** - * This is an example of a Parameterdependencies model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class ParameterdependenciesEditor - extends MultiPageEditorPart - implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker { - /** - * This keeps track of the editing domain that is used to track all changes to the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected AdapterFactoryEditingDomain editingDomain; - - /** - * This is the one adapter factory used for providing views of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ComposedAdapterFactory adapterFactory; - - /** - * This is the content outline page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IContentOutlinePage contentOutlinePage; - - /** - * This is a kludge... - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IStatusLineManager contentOutlineStatusLineManager; - - /** - * This is the content outline page's viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer contentOutlineViewer; - - /** - * This is the property sheet page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected PropertySheetPage propertySheetPage; - - /** - * This is the viewer that shadows the selection in the content outline. - * The parent relation must be correctly defined for this to work. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer selectionViewer; - - /** - * This inverts the roll of parent and child in the content provider and show parents as a tree. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer parentViewer; - - /** - * This shows how a tree view works. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer treeViewer; - - /** - * This shows how a list view works. - * A list viewer doesn't support icons. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ListViewer listViewer; - - /** - * This shows how a table view works. - * A table can be used as a list with icons. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TableViewer tableViewer; - - /** - * This shows how a tree view with columns works. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer treeViewerWithColumns; - - /** - * This keeps track of the active viewer pane, in the book. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ViewerPane currentViewerPane; - - /** - * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Viewer currentViewer; - - /** - * This listens to which ever viewer is active. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelectionChangedListener selectionChangedListener; - - /** - * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); - - /** - * This keeps track of the selection of the editor as a whole. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelection editorSelection = StructuredSelection.EMPTY; - - /** - * The MarkerHelper is responsible for creating workspace resource markers presented - * in Eclipse's Problems View. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected MarkerHelper markerHelper = new EditUIMarkerHelper(); - - /** - * This listens for when the outline becomes active - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IPartListener partListener = - new IPartListener() { - public void partActivated(IWorkbenchPart p) { - if (p instanceof ContentOutline) { - if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) { - getActionBarContributor().setActiveEditor(ParameterdependenciesEditor.this); - - setCurrentViewer(contentOutlineViewer); - } - } - else if (p instanceof PropertySheet) { - if (((PropertySheet)p).getCurrentPage() == propertySheetPage) { - getActionBarContributor().setActiveEditor(ParameterdependenciesEditor.this); - handleActivate(); - } - } - else if (p == ParameterdependenciesEditor.this) { - handleActivate(); - } - } - public void partBroughtToTop(IWorkbenchPart p) { - // Ignore. - } - public void partClosed(IWorkbenchPart p) { - // Ignore. - } - public void partDeactivated(IWorkbenchPart p) { - // Ignore. - } - public void partOpened(IWorkbenchPart p) { - // Ignore. - } - }; - - /** - * Resources that have been removed since last activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> removedResources = new ArrayList<Resource>(); - - /** - * Resources that have been changed since last activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> changedResources = new ArrayList<Resource>(); - - /** - * Resources that have been saved. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> savedResources = new ArrayList<Resource>(); - - /** - * Map to store the diagnostic associated with a resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>(); - - /** - * Controls whether the problem indication should be updated. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean updateProblemIndication = true; - - /** - * Adapter used to update the problem indication when resources are demanded loaded. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EContentAdapter problemIndicationAdapter = - new EContentAdapter() { - @Override - public void notifyChanged(Notification notification) { - if (notification.getNotifier() instanceof Resource) { - switch (notification.getFeatureID(Resource.class)) { - case Resource.RESOURCE__IS_LOADED: - case Resource.RESOURCE__ERRORS: - case Resource.RESOURCE__WARNINGS: { - Resource resource = (Resource)notification.getNotifier(); - Diagnostic diagnostic = analyzeResourceProblems(resource, null); - if (diagnostic.getSeverity() != Diagnostic.OK) { - resourceToDiagnosticMap.put(resource, diagnostic); - } - else { - resourceToDiagnosticMap.remove(resource); - } - - if (updateProblemIndication) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - updateProblemIndication(); - } - }); - } - break; - } - } - } - else { - super.notifyChanged(notification); - } - } - - @Override - protected void setTarget(Resource target) { - basicSetTarget(target); - } - - @Override - protected void unsetTarget(Resource target) { - basicUnsetTarget(target); - } - }; - - /** - * This listens for workspace changes. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IResourceChangeListener resourceChangeListener = - new IResourceChangeListener() { - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - try { - class ResourceDeltaVisitor implements IResourceDeltaVisitor { - protected ResourceSet resourceSet = editingDomain.getResourceSet(); - protected Collection<Resource> changedResources = new ArrayList<Resource>(); - protected Collection<Resource> removedResources = new ArrayList<Resource>(); - - public boolean visit(IResourceDelta delta) { - if (delta.getResource().getType() == IResource.FILE) { - if (delta.getKind() == IResourceDelta.REMOVED || - delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) { - Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false); - if (resource != null) { - if (delta.getKind() == IResourceDelta.REMOVED) { - removedResources.add(resource); - } - else if (!savedResources.remove(resource)) { - changedResources.add(resource); - } - } - } - } - - return true; - } - - public Collection<Resource> getChangedResources() { - return changedResources; - } - - public Collection<Resource> getRemovedResources() { - return removedResources; - } - } - - final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - delta.accept(visitor); - - if (!visitor.getRemovedResources().isEmpty()) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - removedResources.addAll(visitor.getRemovedResources()); - if (!isDirty()) { - getSite().getPage().closeEditor(ParameterdependenciesEditor.this, false); - } - } - }); - } - - if (!visitor.getChangedResources().isEmpty()) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - changedResources.addAll(visitor.getChangedResources()); - if (getSite().getPage().getActiveEditor() == ParameterdependenciesEditor.this) { - handleActivate(); - } - } - }); - } - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - }; - - /** - * Handles activation of the editor or it's associated views. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void handleActivate() { - // Recompute the read only state. - // - if (editingDomain.getResourceToReadOnlyMap() != null) { - editingDomain.getResourceToReadOnlyMap().clear(); - - // Refresh any actions that may become enabled or disabled. - // - setSelection(getSelection()); - } - - if (!removedResources.isEmpty()) { - if (handleDirtyConflict()) { - getSite().getPage().closeEditor(ParameterdependenciesEditor.this, false); - } - else { - removedResources.clear(); - changedResources.clear(); - savedResources.clear(); - } - } - else if (!changedResources.isEmpty()) { - changedResources.removeAll(savedResources); - handleChangedResources(); - changedResources.clear(); - savedResources.clear(); - } - } - - /** - * Handles what to do with changed resources on activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void handleChangedResources() { - if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) { - if (isDirty()) { - changedResources.addAll(editingDomain.getResourceSet().getResources()); - } - editingDomain.getCommandStack().flush(); - - updateProblemIndication = false; - for (Resource resource : changedResources) { - if (resource.isLoaded()) { - resource.unload(); - try { - resource.load(Collections.EMPTY_MAP); - } - catch (IOException exception) { - if (!resourceToDiagnosticMap.containsKey(resource)) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - } - } - } - - if (AdapterFactoryEditingDomain.isStale(editorSelection)) { - setSelection(StructuredSelection.EMPTY); - } - - updateProblemIndication = true; - updateProblemIndication(); - } - } - - /** - * Updates the problems indication with the information described in the specified diagnostic. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void updateProblemIndication() { - if (updateProblemIndication) { - BasicDiagnostic diagnostic = - new BasicDiagnostic - (Diagnostic.OK, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - null, - new Object [] { editingDomain.getResourceSet() }); - for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) { - if (childDiagnostic.getSeverity() != Diagnostic.OK) { - diagnostic.add(childDiagnostic); - } - } - - int lastEditorPage = getPageCount() - 1; - if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) { - ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic); - if (diagnostic.getSeverity() != Diagnostic.OK) { - setActivePage(lastEditorPage); - } - } - else if (diagnostic.getSeverity() != Diagnostic.OK) { - ProblemEditorPart problemEditorPart = new ProblemEditorPart(); - problemEditorPart.setDiagnostic(diagnostic); - problemEditorPart.setMarkerHelper(markerHelper); - try { - addPage(++lastEditorPage, problemEditorPart, getEditorInput()); - setPageText(lastEditorPage, problemEditorPart.getPartName()); - setActivePage(lastEditorPage); - showTabs(); - } - catch (PartInitException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - - if (markerHelper.hasMarkers(editingDomain.getResourceSet())) { - markerHelper.deleteMarkers(editingDomain.getResourceSet()); - if (diagnostic.getSeverity() != Diagnostic.OK) { - try { - markerHelper.createMarkers(diagnostic); - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - } - } - } - - /** - * Shows a dialog that asks if conflicting changes should be discarded. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean handleDirtyConflict() { - return - MessageDialog.openQuestion - (getSite().getShell(), - getString("_UI_FileConflict_label"), - getString("_WARN_FileConflict")); - } - - /** - * This creates a model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ParameterdependenciesEditor() { - super(); - initializeEditingDomain(); - } - - /** - * This sets up the editing domain for the model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void initializeEditingDomain() { - // Create an adapter factory that yields item providers. - // - adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - - adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new RepositoryItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ServicebehaviorItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new SystemItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ParameterdependenciesItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new FunctionsItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new CoreItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new IdentifierItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ResourceconfigurationItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ResourcetypeItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); - - // Create the command stack that will notify this editor as commands are executed. - // - BasicCommandStack commandStack = new BasicCommandStack(); - - // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. - // - commandStack.addCommandStackListener - (new CommandStackListener() { - public void commandStackChanged(final EventObject event) { - getContainer().getDisplay().asyncExec - (new Runnable() { - public void run() { - firePropertyChange(IEditorPart.PROP_DIRTY); - - // Try to select the affected objects. - // - Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); - if (mostRecentCommand != null) { - setSelectionToViewer(mostRecentCommand.getAffectedObjects()); - } - if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) { - propertySheetPage.refresh(); - } - } - }); - } - }); - - // Create the editing domain with a special command stack. - // - editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>()); - } - - /** - * This is here for the listener to be able to call it. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void firePropertyChange(int action) { - super.firePropertyChange(action); - } - - /** - * This sets the selection into whichever viewer is active. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSelectionToViewer(Collection<?> collection) { - final Collection<?> theSelection = collection; - // Make sure it's okay. - // - if (theSelection != null && !theSelection.isEmpty()) { - Runnable runnable = - new Runnable() { - public void run() { - // Try to select the items in the current content viewer of the editor. - // - if (currentViewer != null) { - currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); - } - } - }; - getSite().getShell().getDisplay().asyncExec(runnable); - } - } - - /** - * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. - * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} - * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EditingDomain getEditingDomain() { - return editingDomain; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object [] getElements(Object object) { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object [] getChildren(Object object) { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean hasChildren(Object object) { - Object parent = super.getParent(object); - return parent != null; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object getParent(Object object) { - return null; - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCurrentViewerPane(ViewerPane viewerPane) { - if (currentViewerPane != viewerPane) { - if (currentViewerPane != null) { - currentViewerPane.showFocus(false); - } - currentViewerPane = viewerPane; - } - setCurrentViewer(currentViewerPane.getViewer()); - } - - /** - * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, - * is the current one. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCurrentViewer(Viewer viewer) { - // If it is changing... - // - if (currentViewer != viewer) { - if (selectionChangedListener == null) { - // Create the listener on demand. - // - selectionChangedListener = - new ISelectionChangedListener() { - // This just notifies those things that are affected by the section. - // - public void selectionChanged(SelectionChangedEvent selectionChangedEvent) { - setSelection(selectionChangedEvent.getSelection()); - } - }; - } - - // Stop listening to the old one. - // - if (currentViewer != null) { - currentViewer.removeSelectionChangedListener(selectionChangedListener); - } - - // Start listening to the new one. - // - if (viewer != null) { - viewer.addSelectionChangedListener(selectionChangedListener); - } - - // Remember it. - // - currentViewer = viewer; - - // Set the editors selection based on the current viewer's selection. - // - setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); - } - } - - /** - * This returns the viewer as required by the {@link IViewerProvider} interface. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Viewer getViewer() { - return currentViewer; - } - - /** - * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createContextMenuFor(StructuredViewer viewer) { - MenuManager contextMenu = new MenuManager("#PopUp"); - contextMenu.add(new Separator("additions")); - contextMenu.setRemoveAllWhenShown(true); - contextMenu.addMenuListener(this); - Menu menu= contextMenu.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); - - int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; - Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() }; - viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); - viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); - } - - /** - * This is the method called to load a resource into the editing domain's resource set based on the editor's input. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createModel() { - URI resourceURI = EditUIUtil.getURI(getEditorInput()); - Exception exception = null; - Resource resource = null; - try { - // Load the resource through the editing domain. - // - resource = editingDomain.getResourceSet().getResource(resourceURI, true); - } - catch (Exception e) { - exception = e; - resource = editingDomain.getResourceSet().getResource(resourceURI, false); - } - - Diagnostic diagnostic = analyzeResourceProblems(resource, exception); - if (diagnostic.getSeverity() != Diagnostic.OK) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); - } - - /** - * Returns a diagnostic describing the errors and warnings listed in the resource - * and the specified exception (if any). - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) { - if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) { - BasicDiagnostic basicDiagnostic = - new BasicDiagnostic - (Diagnostic.ERROR, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object [] { exception == null ? (Object)resource : exception }); - basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); - return basicDiagnostic; - } - else if (exception != null) { - return - new BasicDiagnostic - (Diagnostic.ERROR, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object[] { exception }); - } - else { - return Diagnostic.OK_INSTANCE; - } - } - - /** - * This is the method used by the framework to install your own controls. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void createPages() { - // Creates the model from the editor input - // - createModel(); - - // Only creates the other pages if there is something that can be edited - // - if (!getEditingDomain().getResourceSet().getResources().isEmpty()) { - // Create a page for the selection tree view. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ParameterdependenciesEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - Tree tree = new Tree(composite, SWT.MULTI); - TreeViewer newTreeViewer = new TreeViewer(tree); - return newTreeViewer; - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - selectionViewer = (TreeViewer)viewerPane.getViewer(); - selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - - selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - selectionViewer.setInput(editingDomain.getResourceSet()); - selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - viewerPane.setTitle(editingDomain.getResourceSet()); - - new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); - - createContextMenuFor(selectionViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_SelectionPage_label")); - } - - // Create a page for the parent tree view. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ParameterdependenciesEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - Tree tree = new Tree(composite, SWT.MULTI); - TreeViewer newTreeViewer = new TreeViewer(tree); - return newTreeViewer; - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - parentViewer = (TreeViewer)viewerPane.getViewer(); - parentViewer.setAutoExpandLevel(30); - parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory)); - parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(parentViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_ParentPage_label")); - } - - // This is the page for the list viewer - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ParameterdependenciesEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new ListViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - listViewer = (ListViewer)viewerPane.getViewer(); - listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(listViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_ListPage_label")); - } - - // This is the page for the tree viewer - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ParameterdependenciesEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TreeViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - treeViewer = (TreeViewer)viewerPane.getViewer(); - treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); - - createContextMenuFor(treeViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TreePage_label")); - } - - // This is the page for the table viewer. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ParameterdependenciesEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TableViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - tableViewer = (TableViewer)viewerPane.getViewer(); - - Table table = tableViewer.getTable(); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - TableColumn objectColumn = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(3, 100, true)); - objectColumn.setText(getString("_UI_ObjectColumn_label")); - objectColumn.setResizable(true); - - TableColumn selfColumn = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(2, 100, true)); - selfColumn.setText(getString("_UI_SelfColumn_label")); - selfColumn.setResizable(true); - - tableViewer.setColumnProperties(new String [] {"a", "b"}); - tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(tableViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TablePage_label")); - } - - // This is the page for the table tree viewer. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ParameterdependenciesEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TreeViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - treeViewerWithColumns = (TreeViewer)viewerPane.getViewer(); - - Tree tree = treeViewerWithColumns.getTree(); - tree.setLayoutData(new FillLayout()); - tree.setHeaderVisible(true); - tree.setLinesVisible(true); - - TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE); - objectColumn.setText(getString("_UI_ObjectColumn_label")); - objectColumn.setResizable(true); - objectColumn.setWidth(250); - - TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE); - selfColumn.setText(getString("_UI_SelfColumn_label")); - selfColumn.setResizable(true); - selfColumn.setWidth(200); - - treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"}); - treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(treeViewerWithColumns); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); - } - - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - setActivePage(0); - } - }); - } - - // Ensures that this editor will only display the page's tab - // area if there are more than one page - // - getContainer().addControlListener - (new ControlAdapter() { - boolean guard = false; - @Override - public void controlResized(ControlEvent event) { - if (!guard) { - guard = true; - hideTabs(); - guard = false; - } - } - }); - - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - updateProblemIndication(); - } - }); - } - - /** - * If there is just one page in the multi-page editor part, - * this hides the single tab at the bottom. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void hideTabs() { - if (getPageCount() <= 1) { - setPageText(0, ""); - if (getContainer() instanceof CTabFolder) { - ((CTabFolder)getContainer()).setTabHeight(1); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y + 6); - } - } - } - - /** - * If there is more than one page in the multi-page editor part, - * this shows the tabs at the bottom. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void showTabs() { - if (getPageCount() > 1) { - setPageText(0, getString("_UI_SelectionPage_label")); - if (getContainer() instanceof CTabFolder) { - ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y - 6); - } - } - } - - /** - * This is used to track the active viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void pageChange(int pageIndex) { - super.pageChange(pageIndex); - - if (contentOutlinePage != null) { - handleContentOutlineSelection(contentOutlinePage.getSelection()); - } - } - - /** - * This is how the framework determines which interfaces we implement. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class key) { - if (key.equals(IContentOutlinePage.class)) { - return showOutlineView() ? getContentOutlinePage() : null; - } - else if (key.equals(IPropertySheetPage.class)) { - return getPropertySheetPage(); - } - else if (key.equals(IGotoMarker.class)) { - return this; - } - else { - return super.getAdapter(key); - } - } - - /** - * This accesses a cached version of the content outliner. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IContentOutlinePage getContentOutlinePage() { - if (contentOutlinePage == null) { - // The content outline is just a tree. - // - class MyContentOutlinePage extends ContentOutlinePage { - @Override - public void createControl(Composite parent) { - super.createControl(parent); - contentOutlineViewer = getTreeViewer(); - contentOutlineViewer.addSelectionChangedListener(this); - - // Set up the tree viewer. - // - contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - contentOutlineViewer.setInput(editingDomain.getResourceSet()); - - // Make sure our popups work. - // - createContextMenuFor(contentOutlineViewer); - - if (!editingDomain.getResourceSet().getResources().isEmpty()) { - // Select the root object in the view. - // - contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - } - } - - @Override - public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { - super.makeContributions(menuManager, toolBarManager, statusLineManager); - contentOutlineStatusLineManager = statusLineManager; - } - - @Override - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - } - - contentOutlinePage = new MyContentOutlinePage(); - - // Listen to selection so that we can handle it is a special way. - // - contentOutlinePage.addSelectionChangedListener - (new ISelectionChangedListener() { - // This ensures that we handle selections correctly. - // - public void selectionChanged(SelectionChangedEvent event) { - handleContentOutlineSelection(event.getSelection()); - } - }); - } - - return contentOutlinePage; - } - - /** - * This accesses a cached version of the property sheet. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IPropertySheetPage getPropertySheetPage() { - if (propertySheetPage == null) { - propertySheetPage = - new ExtendedPropertySheetPage(editingDomain) { - @Override - public void setSelectionToViewer(List<?> selection) { - ParameterdependenciesEditor.this.setSelectionToViewer(selection); - ParameterdependenciesEditor.this.setFocus(); - } - - @Override - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - }; - propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); - } - - return propertySheetPage; - } - - /** - * This deals with how we want selection in the outliner to affect the other views. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void handleContentOutlineSelection(ISelection selection) { - if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { - Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator(); - if (selectedElements.hasNext()) { - // Get the first selected element. - // - Object selectedElement = selectedElements.next(); - - // If it's the selection viewer, then we want it to select the same selection as this selection. - // - if (currentViewerPane.getViewer() == selectionViewer) { - ArrayList<Object> selectionList = new ArrayList<Object>(); - selectionList.add(selectedElement); - while (selectedElements.hasNext()) { - selectionList.add(selectedElements.next()); - } - - // Set the selection to the widget. - // - selectionViewer.setSelection(new StructuredSelection(selectionList)); - } - else { - // Set the input to the widget. - // - if (currentViewerPane.getViewer().getInput() != selectedElement) { - currentViewerPane.getViewer().setInput(selectedElement); - currentViewerPane.setTitle(selectedElement); - } - } - } - } - } - - /** - * This is for implementing {@link IEditorPart} and simply tests the command stack. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean isDirty() { - return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded(); - } - - /** - * This is for implementing {@link IEditorPart} and simply saves the model file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void doSave(IProgressMonitor progressMonitor) { - // Save only resources that have actually changed. - // - final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); - saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); - - // Do the work within an operation because this is a long running activity that modifies the workbench. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - // This is the method that gets invoked when the operation runs. - // - @Override - public void execute(IProgressMonitor monitor) { - // Save the resources to the file system. - // - boolean first = true; - for (Resource resource : editingDomain.getResourceSet().getResources()) { - if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { - try { - long timeStamp = resource.getTimeStamp(); - resource.save(saveOptions); - if (resource.getTimeStamp() != timeStamp) { - savedResources.add(resource); - } - } - catch (Exception exception) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - first = false; - } - } - } - }; - - updateProblemIndication = false; - try { - // This runs the options, and shows progress. - // - new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); - - // Refresh the necessary state. - // - ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); - firePropertyChange(IEditorPart.PROP_DIRTY); - } - catch (Exception exception) { - // Something went wrong that shouldn't. - // - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - updateProblemIndication = true; - updateProblemIndication(); - } - - /** - * This returns whether something has been persisted to the URI of the specified resource. - * The implementation uses the URI converter from the editor's resource set to try to open an input stream. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean isPersisted(Resource resource) { - boolean result = false; - try { - InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); - if (stream != null) { - result = true; - stream.close(); - } - } - catch (IOException e) { - // Ignore - } - return result; - } - - /** - * This always returns true because it is not currently supported. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean isSaveAsAllowed() { - return true; - } - - /** - * This also changes the editor's input. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void doSaveAs() { - SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); - saveAsDialog.open(); - IPath path = saveAsDialog.getResult(); - if (path != null) { - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - if (file != null) { - doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void doSaveAs(URI uri, IEditorInput editorInput) { - (editingDomain.getResourceSet().getResources().get(0)).setURI(uri); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - IProgressMonitor progressMonitor = - getActionBars().getStatusLineManager() != null ? - getActionBars().getStatusLineManager().getProgressMonitor() : - new NullProgressMonitor(); - doSave(progressMonitor); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void gotoMarker(IMarker marker) { - try { - if (marker.getType().equals(EValidator.MARKER)) { - String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null); - if (uriAttribute != null) { - URI uri = URI.createURI(uriAttribute); - EObject eObject = editingDomain.getResourceSet().getEObject(uri, true); - if (eObject != null) { - setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject))); - } - } - } - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - - /** - * This is called during startup. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void init(IEditorSite site, IEditorInput editorInput) { - setSite(site); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - site.setSelectionProvider(this); - site.getPage().addPartListener(partListener); - ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setFocus() { - if (currentViewerPane != null) { - currentViewerPane.setFocus(); - } - else { - getControl(getActivePage()).setFocus(); - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ISelection getSelection() { - return editorSelection; - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. - * Calling this result will notify the listeners. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSelection(ISelection selection) { - editorSelection = selection; - - for (ISelectionChangedListener listener : selectionChangedListeners) { - listener.selectionChanged(new SelectionChangedEvent(this, selection)); - } - setStatusLineManager(selection); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setStatusLineManager(ISelection selection) { - IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? - contentOutlineStatusLineManager : getActionBars().getStatusLineManager(); - - if (statusLineManager != null) { - if (selection instanceof IStructuredSelection) { - Collection<?> collection = ((IStructuredSelection)selection).toList(); - switch (collection.size()) { - case 0: { - statusLineManager.setMessage(getString("_UI_NoObjectSelected")); - break; - } - case 1: { - String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next()); - statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); - break; - } - default: { - statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size()))); - break; - } - } - } - else { - statusLineManager.setMessage(""); - } - } - } - - /** - * This looks up a string in the plugin's plugin.properties file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static String getString(String key) { - return ApplicationlevelEditorPlugin.INSTANCE.getString(key); - } - - /** - * This looks up a string in plugin.properties, making a substitution. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static String getString(String key, Object s1) { - return ApplicationlevelEditorPlugin.INSTANCE.getString(key, new Object [] { s1 }); - } - - /** - * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void menuAboutToShow(IMenuManager menuManager) { - ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EditingDomainActionBarContributor getActionBarContributor() { - return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IActionBars getActionBars() { - return getActionBarContributor().getActionBars(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public AdapterFactory getAdapterFactory() { - return adapterFactory; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void dispose() { - updateProblemIndication = false; - - ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); - - getSite().getPage().removePartListener(partListener); - - adapterFactory.dispose(); - - if (getActionBarContributor().getActiveEditor() == this) { - getActionBarContributor().setActiveEditor(null); - } - - if (propertySheetPage != null) { - propertySheetPage.dispose(); - } - - if (contentOutlinePage != null) { - contentOutlinePage.dispose(); - } - - super.dispose(); - } - - /** - * Returns whether the outline view should be presented to the user. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean showOutlineView() { - return true; - } -} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesModelWizard.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesModelWizard.java deleted file mode 100644 index 1c27172d..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/parameterdependencies/presentation/ParameterdependenciesModelWizard.java +++ /dev/null @@ -1,630 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.parameterdependencies.presentation; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.StringTokenizer; - -import org.eclipse.emf.common.CommonPlugin; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.jface.dialogs.MessageDialog; - -import org.eclipse.jface.viewers.IStructuredSelection; - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; - -import org.eclipse.swt.SWT; - -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.ModifyEvent; - -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; - -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; - -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; - -import edu.kit.ipd.descartes.mm.parameterdependencies.ParameterdependenciesFactory; -import edu.kit.ipd.descartes.mm.parameterdependencies.ParameterdependenciesPackage; -import edu.kit.ipd.descartes.mm.applicationlevel.provider.ApplicationlevelEditPlugin; - - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import org.eclipse.core.runtime.Path; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; - -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; - - -/** - * This is a simple wizard for creating a new model file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class ParameterdependenciesModelWizard extends Wizard implements INewWizard { - /** - * The supported extensions for created files. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final List<String> FILE_EXTENSIONS = - Collections.unmodifiableList(Arrays.asList(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ParameterdependenciesEditorFilenameExtensions").split("\\s*,\\s*"))); - - /** - * A formatted list of supported file extensions, suitable for display. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String FORMATTED_FILE_EXTENSIONS = - ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ParameterdependenciesEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); - - /** - * This caches an instance of the model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ParameterdependenciesPackage parameterdependenciesPackage = ParameterdependenciesPackage.eINSTANCE; - - /** - * This caches an instance of the model factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ParameterdependenciesFactory parameterdependenciesFactory = parameterdependenciesPackage.getParameterdependenciesFactory(); - - /** - * This is the file creation page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ParameterdependenciesModelWizardNewFileCreationPage newFileCreationPage; - - /** - * This is the initial object creation page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ParameterdependenciesModelWizardInitialObjectCreationPage initialObjectCreationPage; - - /** - * Remember the selection during initialization for populating the default container. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IStructuredSelection selection; - - /** - * Remember the workbench during initialization. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IWorkbench workbench; - - /** - * Caches the names of the types that can be created as the root object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected List<String> initialObjectNames; - - /** - * This just records the information. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.workbench = workbench; - this.selection = selection; - setWindowTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_label")); - setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(ApplicationlevelEditorPlugin.INSTANCE.getImage("full/wizban/NewParameterdependencies"))); - } - - /** - * Returns the names of the types that can be created as the root object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<String> getInitialObjectNames() { - if (initialObjectNames == null) { - initialObjectNames = new ArrayList<String>(); - for (EClassifier eClassifier : parameterdependenciesPackage.getEClassifiers()) { - if (eClassifier instanceof EClass) { - EClass eClass = (EClass)eClassifier; - if (!eClass.isAbstract()) { - initialObjectNames.add(eClass.getName()); - } - } - } - Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator()); - } - return initialObjectNames; - } - - /** - * Create a new model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EObject createInitialModel() { - EClass eClass = (EClass)parameterdependenciesPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName()); - EObject rootObject = parameterdependenciesFactory.create(eClass); - return rootObject; - } - - /** - * Do the work after everything is specified. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean performFinish() { - try { - // Remember the file. - // - final IFile modelFile = getModelFile(); - - // Do the work within an operation. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - @Override - protected void execute(IProgressMonitor progressMonitor) { - try { - // Create a resource set - // - ResourceSet resourceSet = new ResourceSetImpl(); - - // Get the URI of the model file. - // - URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true); - - // Create a resource for this file. - // - Resource resource = resourceSet.createResource(fileURI); - - // Add the initial model object to the contents. - // - EObject rootObject = createInitialModel(); - if (rootObject != null) { - resource.getContents().add(rootObject); - } - - // Save the contents of the resource to the file system. - // - Map<Object, Object> options = new HashMap<Object, Object>(); - options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding()); - resource.save(options); - } - catch (Exception exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - finally { - progressMonitor.done(); - } - } - }; - - getContainer().run(false, false, operation); - - // Select the new file resource in the current view. - // - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IWorkbenchPage page = workbenchWindow.getActivePage(); - final IWorkbenchPart activePart = page.getActivePart(); - if (activePart instanceof ISetSelectionTarget) { - final ISelection targetSelection = new StructuredSelection(modelFile); - getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - ((ISetSelectionTarget)activePart).selectReveal(targetSelection); - } - }); - } - - // Open an editor on the new file. - // - try { - page.openEditor - (new FileEditorInput(modelFile), - workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId()); - } - catch (PartInitException exception) { - MessageDialog.openError(workbenchWindow.getShell(), ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); - return false; - } - - return true; - } - catch (Exception exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - return false; - } - } - - /** - * This is the one page of the wizard. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class ParameterdependenciesModelWizardNewFileCreationPage extends WizardNewFileCreationPage { - /** - * Pass in the selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ParameterdependenciesModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) { - super(pageId, selection); - } - - /** - * The framework calls this to see if the file is correct. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected boolean validatePage() { - if (super.validatePage()) { - String extension = new Path(getFileName()).getFileExtension(); - if (extension == null || !FILE_EXTENSIONS.contains(extension)) { - String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; - setErrorMessage(ApplicationlevelEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS })); - return false; - } - return true; - } - return false; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IFile getModelFile() { - return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName())); - } - } - - /** - * This is the page where the type of object to create is selected. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class ParameterdependenciesModelWizardInitialObjectCreationPage extends WizardPage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Combo initialObjectField; - - /** - * @generated - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - */ - protected List<String> encodings; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Combo encodingField; - - /** - * Pass in the selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ParameterdependenciesModelWizardInitialObjectCreationPage(String pageId) { - super(pageId); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); { - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.verticalSpacing = 12; - composite.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - } - - Label containerLabel = new Label(composite, SWT.LEFT); - { - containerLabel.setText(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ModelObject")); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - containerLabel.setLayoutData(data); - } - - initialObjectField = new Combo(composite, SWT.BORDER); - { - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - initialObjectField.setLayoutData(data); - } - - for (String objectName : getInitialObjectNames()) { - initialObjectField.add(getLabel(objectName)); - } - - if (initialObjectField.getItemCount() == 1) { - initialObjectField.select(0); - } - initialObjectField.addModifyListener(validator); - - Label encodingLabel = new Label(composite, SWT.LEFT); - { - encodingLabel.setText(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_XMLEncoding")); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - encodingLabel.setLayoutData(data); - } - encodingField = new Combo(composite, SWT.BORDER); - { - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - encodingField.setLayoutData(data); - } - - for (String encoding : getEncodings()) { - encodingField.add(encoding); - } - - encodingField.select(0); - encodingField.addModifyListener(validator); - - setPageComplete(validatePage()); - setControl(composite); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ModifyListener validator = - new ModifyListener() { - public void modifyText(ModifyEvent e) { - setPageComplete(validatePage()); - } - }; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean validatePage() { - return getInitialObjectName() != null && getEncodings().contains(encodingField.getText()); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - if (initialObjectField.getItemCount() == 1) { - initialObjectField.clearSelection(); - encodingField.setFocus(); - } - else { - encodingField.clearSelection(); - initialObjectField.setFocus(); - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getInitialObjectName() { - String label = initialObjectField.getText(); - - for (String name : getInitialObjectNames()) { - if (getLabel(name).equals(label)) { - return name; - } - } - return null; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getEncoding() { - return encodingField.getText(); - } - - /** - * Returns the label for the specified type name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected String getLabel(String typeName) { - try { - return ApplicationlevelEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); - } - catch(MissingResourceException mre) { - ApplicationlevelEditorPlugin.INSTANCE.log(mre); - } - return typeName; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<String> getEncodings() { - if (encodings == null) { - encodings = new ArrayList<String>(); - for (StringTokenizer stringTokenizer = new StringTokenizer(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) { - encodings.add(stringTokenizer.nextToken()); - } - } - return encodings; - } - } - - /** - * The framework calls this to create the contents of the wizard. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void addPages() { - // Create a page, set the title, and the initial model file name. - // - newFileCreationPage = new ParameterdependenciesModelWizardNewFileCreationPage("Whatever", selection); - newFileCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ParameterdependenciesModelWizard_label")); - newFileCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ParameterdependenciesModelWizard_description")); - newFileCreationPage.setFileName(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ParameterdependenciesEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); - addPage(newFileCreationPage); - - // Try and get the resource selection to determine a current directory for the file dialog. - // - if (selection != null && !selection.isEmpty()) { - // Get the resource... - // - Object selectedElement = selection.iterator().next(); - if (selectedElement instanceof IResource) { - // Get the resource parent, if its a file. - // - IResource selectedResource = (IResource)selectedElement; - if (selectedResource.getType() == IResource.FILE) { - selectedResource = selectedResource.getParent(); - } - - // This gives us a directory... - // - if (selectedResource instanceof IFolder || selectedResource instanceof IProject) { - // Set this for the container. - // - newFileCreationPage.setContainerFullPath(selectedResource.getFullPath()); - - // Make up a unique new name here. - // - String defaultModelBaseFilename = ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ParameterdependenciesEditorFilenameDefaultBase"); - String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0); - String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; - for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) { - modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; - } - newFileCreationPage.setFileName(modelFilename); - } - } - } - initialObjectCreationPage = new ParameterdependenciesModelWizardInitialObjectCreationPage("Whatever2"); - initialObjectCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ParameterdependenciesModelWizard_label")); - initialObjectCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description")); - addPage(initialObjectCreationPage); - } - - /** - * Get the file from the page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IFile getModelFile() { - return newFileCreationPage.getModelFile(); - } - -} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryActionBarContributor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryActionBarContributor.java deleted file mode 100644 index 7fc2253b..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryActionBarContributor.java +++ /dev/null @@ -1,426 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.repository.presentation; - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; - -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; - -import org.eclipse.emf.edit.ui.action.ControlAction; -import org.eclipse.emf.edit.ui.action.CreateChildAction; -import org.eclipse.emf.edit.ui.action.CreateSiblingAction; -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; -import org.eclipse.emf.edit.ui.action.LoadResourceAction; -import org.eclipse.emf.edit.ui.action.ValidateAction; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.action.SubContributionItem; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; - -/** - * This is the action bar contributor for the Repository model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class RepositoryActionBarContributor - extends EditingDomainActionBarContributor - implements ISelectionChangedListener { - /** - * This keeps track of the active editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IEditorPart activeEditorPart; - - /** - * This keeps track of the current selection provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelectionProvider selectionProvider; - - /** - * This action opens the Properties view. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IAction showPropertiesViewAction = - new Action(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { - @Override - public void run() { - try { - getPage().showView("org.eclipse.ui.views.PropertySheet"); - } - catch (PartInitException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - }; - - /** - * This action refreshes the viewer of the current editor if the editor - * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IAction refreshViewerAction = - new Action(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { - @Override - public boolean isEnabled() { - return activeEditorPart instanceof IViewerProvider; - } - - @Override - public void run() { - if (activeEditorPart instanceof IViewerProvider) { - Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); - if (viewer != null) { - viewer.refresh(); - } - } - } - }; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> createChildActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateChild actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IMenuManager createChildMenuManager; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> createSiblingActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateSibling actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IMenuManager createSiblingMenuManager; - - /** - * This creates an instance of the contributor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public RepositoryActionBarContributor() { - super(ADDITIONS_LAST_STYLE); - loadResourceAction = new LoadResourceAction(); - validateAction = new ValidateAction(); - controlAction = new ControlAction(); - } - - /** - * This adds Separators for editor additions to the tool bar. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void contributeToToolBar(IToolBarManager toolBarManager) { - toolBarManager.add(new Separator("repository-settings")); - toolBarManager.add(new Separator("repository-additions")); - } - - /** - * This adds to the menu bar a menu and some separators for editor additions, - * as well as the sub-menus for object creation items. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void contributeToMenu(IMenuManager menuManager) { - super.contributeToMenu(menuManager); - - IMenuManager submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryEditor_menu"), "edu.kit.ipd.descartes.mm.repositoryMenuID"); - menuManager.insertAfter("additions", submenuManager); - submenuManager.add(new Separator("settings")); - submenuManager.add(new Separator("actions")); - submenuManager.add(new Separator("additions")); - submenuManager.add(new Separator("additions-end")); - - // Prepare for CreateChild item addition or removal. - // - createChildMenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); - submenuManager.insertBefore("additions", createChildMenuManager); - - // Prepare for CreateSibling item addition or removal. - // - createSiblingMenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); - submenuManager.insertBefore("additions", createSiblingMenuManager); - - // Force an update because Eclipse hides empty menus now. - // - submenuManager.addMenuListener - (new IMenuListener() { - public void menuAboutToShow(IMenuManager menuManager) { - menuManager.updateAll(true); - } - }); - - addGlobalActions(submenuManager); - } - - /** - * When the active editor changes, this remembers the change and registers with it as a selection provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setActiveEditor(IEditorPart part) { - super.setActiveEditor(part); - activeEditorPart = part; - - // Switch to the new selection provider. - // - if (selectionProvider != null) { - selectionProvider.removeSelectionChangedListener(this); - } - if (part == null) { - selectionProvider = null; - } - else { - selectionProvider = part.getSite().getSelectionProvider(); - selectionProvider.addSelectionChangedListener(this); - - // Fake a selection changed event to update the menus. - // - if (selectionProvider.getSelection() != null) { - selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection())); - } - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, - * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings - * that can be added to the selected object and updating the menus accordingly. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void selectionChanged(SelectionChangedEvent event) { - // Remove any menu items for old selection. - // - if (createChildMenuManager != null) { - depopulateManager(createChildMenuManager, createChildActions); - } - if (createSiblingMenuManager != null) { - depopulateManager(createSiblingMenuManager, createSiblingActions); - } - - // Query the new selection for appropriate new child/sibling descriptors - // - Collection<?> newChildDescriptors = null; - Collection<?> newSiblingDescriptors = null; - - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) { - Object object = ((IStructuredSelection)selection).getFirstElement(); - - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); - - newChildDescriptors = domain.getNewChildDescriptors(object, null); - newSiblingDescriptors = domain.getNewChildDescriptors(null, object); - } - - // Generate actions for selection; populate and redraw the menus. - // - createChildActions = generateCreateChildActions(newChildDescriptors, selection); - createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection); - - if (createChildMenuManager != null) { - populateManager(createChildMenuManager, createChildActions, null); - createChildMenuManager.update(true); - } - if (createSiblingMenuManager != null) { - populateManager(createSiblingMenuManager, createSiblingActions, null); - createSiblingMenuManager.update(true); - } - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, - * and returns the collection of these actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) { - Collection<IAction> actions = new ArrayList<IAction>(); - if (descriptors != null) { - for (Object descriptor : descriptors) { - actions.add(new CreateChildAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>, - * and returns the collection of these actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) { - Collection<IAction> actions = new ArrayList<IAction>(); - if (descriptors != null) { - for (Object descriptor : descriptors) { - actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, - * by inserting them before the specified contribution item <code>contributionID</code>. - * If <code>contributionID</code> is <code>null</code>, they are simply added. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { - if (actions != null) { - for (IAction action : actions) { - if (contributionID != null) { - manager.insertBefore(contributionID, action); - } - else { - manager.add(action); - } - } - } - } - - /** - * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) { - if (actions != null) { - IContributionItem[] items = manager.getItems(); - for (int i = 0; i < items.length; i++) { - // Look into SubContributionItems - // - IContributionItem contributionItem = items[i]; - while (contributionItem instanceof SubContributionItem) { - contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); - } - - // Delete the ActionContributionItems with matching action. - // - if (contributionItem instanceof ActionContributionItem) { - IAction action = ((ActionContributionItem)contributionItem).getAction(); - if (actions.contains(action)) { - manager.remove(contributionItem); - } - } - } - } - } - - /** - * This populates the pop-up menu before it appears. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void menuAboutToShow(IMenuManager menuManager) { - super.menuAboutToShow(menuManager); - MenuManager submenuManager = null; - - submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); - populateManager(submenuManager, createChildActions, null); - menuManager.insertBefore("edit", submenuManager); - - submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); - populateManager(submenuManager, createSiblingActions, null); - menuManager.insertBefore("edit", submenuManager); - } - - /** - * This inserts global actions before the "additions-end" separator. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void addGlobalActions(IMenuManager menuManager) { - menuManager.insertAfter("additions-end", new Separator("ui-actions")); - menuManager.insertAfter("ui-actions", showPropertiesViewAction); - - refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); - menuManager.insertAfter("ui-actions", refreshViewerAction); - - super.addGlobalActions(menuManager); - } - - /** - * This ensures that a delete action will clean up all references to deleted objects. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected boolean removeAllReferencesOnDelete() { - return true; - } - -} \ No newline at end of file diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorActionBarContributor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesActionBarContributor.java similarity index 96% rename from edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorActionBarContributor.java rename to edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesActionBarContributor.java index 5f3d1bbc..10731d5b 100644 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorActionBarContributor.java +++ b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesActionBarContributor.java @@ -1,7 +1,7 @@ /** * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT */ -package edu.kit.ipd.descartes.mm.servicebehavior.presentation; +package edu.kit.ipd.descartes.mm.repository_composites.presentation; import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; @@ -43,12 +43,12 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PartInitException; /** - * This is the action bar contributor for the Servicebehavior model editor. + * This is the action bar contributor for the RepositoryComposites model editor. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ -public class ServicebehaviorActionBarContributor +public class RepositoryCompositesActionBarContributor extends EditingDomainActionBarContributor implements ISelectionChangedListener { /** @@ -151,7 +151,7 @@ public class ServicebehaviorActionBarContributor * <!-- end-user-doc --> * @generated */ - public ServicebehaviorActionBarContributor() { + public RepositoryCompositesActionBarContributor() { super(ADDITIONS_LAST_STYLE); loadResourceAction = new LoadResourceAction(); validateAction = new ValidateAction(); @@ -166,8 +166,8 @@ public class ServicebehaviorActionBarContributor */ @Override public void contributeToToolBar(IToolBarManager toolBarManager) { - toolBarManager.add(new Separator("servicebehavior-settings")); - toolBarManager.add(new Separator("servicebehavior-additions")); + toolBarManager.add(new Separator("repositorycomposites-settings")); + toolBarManager.add(new Separator("repositorycomposites-additions")); } /** @@ -181,7 +181,7 @@ public class ServicebehaviorActionBarContributor public void contributeToMenu(IMenuManager menuManager) { super.contributeToMenu(menuManager); - IMenuManager submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ServicebehaviorEditor_menu"), "edu.kit.ipd.descartes.mm.servicebehaviorMenuID"); + IMenuManager submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryCompositesEditor_menu"), "edu.kit.ipd.descartes.mm.repository_compositesMenuID"); menuManager.insertAfter("additions", submenuManager); submenuManager.add(new Separator("settings")); submenuManager.add(new Separator("actions")); @@ -423,4 +423,4 @@ public class ServicebehaviorActionBarContributor return true; } -} \ No newline at end of file +} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryEditor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesEditor.java similarity index 97% rename from edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryEditor.java rename to edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesEditor.java index 4a662047..0a697fd8 100644 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryEditor.java +++ b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesEditor.java @@ -1,7 +1,7 @@ /** * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT */ -package edu.kit.ipd.descartes.mm.repository.presentation; +package edu.kit.ipd.descartes.mm.repository_composites.presentation; import java.io.IOException; @@ -154,7 +154,7 @@ import org.eclipse.emf.edit.ui.util.EditUIUtil; import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; -import edu.kit.ipd.descartes.mm.repository.provider.RepositoryItemProviderAdapterFactory; +import edu.kit.ipd.descartes.mm.repository_composites.provider.RepositoryCompositesItemProviderAdapterFactory; import edu.kit.ipd.descartes.identifier.provider.IdentifierItemProviderAdapterFactory; @@ -166,6 +166,8 @@ import edu.kit.ipd.descartes.mm.functions.provider.FunctionsItemProviderAdapterF import edu.kit.ipd.descartes.mm.parameterdependencies.provider.ParameterdependenciesItemProviderAdapterFactory; +import edu.kit.ipd.descartes.mm.repository.provider.RepositoryItemProviderAdapterFactory; + import edu.kit.ipd.descartes.mm.resourceconfiguration.provider.ResourceconfigurationItemProviderAdapterFactory; import edu.kit.ipd.descartes.mm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory; @@ -178,12 +180,12 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation; /** - * This is an example of a Repository model editor. + * This is an example of a RepositoryComposites model editor. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ -public class RepositoryEditor +public class RepositoryCompositesEditor extends MultiPageEditorPart implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker { /** @@ -345,18 +347,18 @@ public class RepositoryEditor public void partActivated(IWorkbenchPart p) { if (p instanceof ContentOutline) { if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) { - getActionBarContributor().setActiveEditor(RepositoryEditor.this); + getActionBarContributor().setActiveEditor(RepositoryCompositesEditor.this); setCurrentViewer(contentOutlineViewer); } } else if (p instanceof PropertySheet) { if (((PropertySheet)p).getCurrentPage() == propertySheetPage) { - getActionBarContributor().setActiveEditor(RepositoryEditor.this); + getActionBarContributor().setActiveEditor(RepositoryCompositesEditor.this); handleActivate(); } } - else if (p == RepositoryEditor.this) { + else if (p == RepositoryCompositesEditor.this) { handleActivate(); } } @@ -519,7 +521,7 @@ public class RepositoryEditor public void run() { removedResources.addAll(visitor.getRemovedResources()); if (!isDirty()) { - getSite().getPage().closeEditor(RepositoryEditor.this, false); + getSite().getPage().closeEditor(RepositoryCompositesEditor.this, false); } } }); @@ -530,7 +532,7 @@ public class RepositoryEditor (new Runnable() { public void run() { changedResources.addAll(visitor.getChangedResources()); - if (getSite().getPage().getActiveEditor() == RepositoryEditor.this) { + if (getSite().getPage().getActiveEditor() == RepositoryCompositesEditor.this) { handleActivate(); } } @@ -562,7 +564,7 @@ public class RepositoryEditor if (!removedResources.isEmpty()) { if (handleDirtyConflict()) { - getSite().getPage().closeEditor(RepositoryEditor.this, false); + getSite().getPage().closeEditor(RepositoryCompositesEditor.this, false); } else { removedResources.clear(); @@ -692,7 +694,7 @@ public class RepositoryEditor * <!-- end-user-doc --> * @generated */ - public RepositoryEditor() { + public RepositoryCompositesEditor() { super(); initializeEditingDomain(); } @@ -709,11 +711,12 @@ public class RepositoryEditor adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); + adapterFactory.addAdapterFactory(new FunctionsItemProviderAdapterFactory()); + adapterFactory.addAdapterFactory(new ParameterdependenciesItemProviderAdapterFactory()); + adapterFactory.addAdapterFactory(new RepositoryCompositesItemProviderAdapterFactory()); adapterFactory.addAdapterFactory(new RepositoryItemProviderAdapterFactory()); adapterFactory.addAdapterFactory(new ServicebehaviorItemProviderAdapterFactory()); adapterFactory.addAdapterFactory(new SystemItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ParameterdependenciesItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new FunctionsItemProviderAdapterFactory()); adapterFactory.addAdapterFactory(new CoreItemProviderAdapterFactory()); adapterFactory.addAdapterFactory(new IdentifierItemProviderAdapterFactory()); adapterFactory.addAdapterFactory(new ResourceconfigurationItemProviderAdapterFactory()); @@ -1031,7 +1034,7 @@ public class RepositoryEditor // { ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), RepositoryEditor.this) { + new ViewerPane(getSite().getPage(), RepositoryCompositesEditor.this) { @Override public Viewer createViewer(Composite composite) { Tree tree = new Tree(composite, SWT.MULTI); @@ -1065,7 +1068,7 @@ public class RepositoryEditor // { ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), RepositoryEditor.this) { + new ViewerPane(getSite().getPage(), RepositoryCompositesEditor.this) { @Override public Viewer createViewer(Composite composite) { Tree tree = new Tree(composite, SWT.MULTI); @@ -1094,7 +1097,7 @@ public class RepositoryEditor // { ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), RepositoryEditor.this) { + new ViewerPane(getSite().getPage(), RepositoryCompositesEditor.this) { @Override public Viewer createViewer(Composite composite) { return new ListViewer(composite); @@ -1119,7 +1122,7 @@ public class RepositoryEditor // { ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), RepositoryEditor.this) { + new ViewerPane(getSite().getPage(), RepositoryCompositesEditor.this) { @Override public Viewer createViewer(Composite composite) { return new TreeViewer(composite); @@ -1146,7 +1149,7 @@ public class RepositoryEditor // { ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), RepositoryEditor.this) { + new ViewerPane(getSite().getPage(), RepositoryCompositesEditor.this) { @Override public Viewer createViewer(Composite composite) { return new TableViewer(composite); @@ -1189,7 +1192,7 @@ public class RepositoryEditor // { ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), RepositoryEditor.this) { + new ViewerPane(getSite().getPage(), RepositoryCompositesEditor.this) { @Override public Viewer createViewer(Composite composite) { return new TreeViewer(composite); @@ -1410,8 +1413,8 @@ public class RepositoryEditor new ExtendedPropertySheetPage(editingDomain) { @Override public void setSelectionToViewer(List<?> selection) { - RepositoryEditor.this.setSelectionToViewer(selection); - RepositoryEditor.this.setFocus(); + RepositoryCompositesEditor.this.setSelectionToViewer(selection); + RepositoryCompositesEditor.this.setFocus(); } @Override diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryModelWizard.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesModelWizard.java similarity index 87% rename from edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryModelWizard.java rename to edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesModelWizard.java index f603a696..bd9bc41a 100644 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository/presentation/RepositoryModelWizard.java +++ b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/repository_composites/presentation/RepositoryCompositesModelWizard.java @@ -1,7 +1,7 @@ /** * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT */ -package edu.kit.ipd.descartes.mm.repository.presentation; +package edu.kit.ipd.descartes.mm.repository_composites.presentation; import java.util.ArrayList; @@ -70,8 +70,8 @@ import org.eclipse.ui.dialogs.WizardNewFileCreationPage; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.ISetSelectionTarget; -import edu.kit.ipd.descartes.mm.repository.RepositoryFactory; -import edu.kit.ipd.descartes.mm.repository.RepositoryPackage; +import edu.kit.ipd.descartes.mm.repository_composites.RepositoryCompositesFactory; +import edu.kit.ipd.descartes.mm.repository_composites.RepositoryCompositesPackage; import edu.kit.ipd.descartes.mm.applicationlevel.provider.ApplicationlevelEditPlugin; @@ -94,7 +94,7 @@ import org.eclipse.ui.PartInitException; * <!-- end-user-doc --> * @generated */ -public class RepositoryModelWizard extends Wizard implements INewWizard { +public class RepositoryCompositesModelWizard extends Wizard implements INewWizard { /** * The supported extensions for created files. * <!-- begin-user-doc --> @@ -102,7 +102,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * @generated */ public static final List<String> FILE_EXTENSIONS = - Collections.unmodifiableList(Arrays.asList(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryEditorFilenameExtensions").split("\\s*,\\s*"))); + Collections.unmodifiableList(Arrays.asList(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryCompositesEditorFilenameExtensions").split("\\s*,\\s*"))); /** * A formatted list of supported file extensions, suitable for display. @@ -111,7 +111,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * @generated */ public static final String FORMATTED_FILE_EXTENSIONS = - ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); + ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryCompositesEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); /** * This caches an instance of the model package. @@ -119,7 +119,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * <!-- end-user-doc --> * @generated */ - protected RepositoryPackage repositoryPackage = RepositoryPackage.eINSTANCE; + protected RepositoryCompositesPackage repositoryCompositesPackage = RepositoryCompositesPackage.eINSTANCE; /** * This caches an instance of the model factory. @@ -127,7 +127,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * <!-- end-user-doc --> * @generated */ - protected RepositoryFactory repositoryFactory = repositoryPackage.getRepositoryFactory(); + protected RepositoryCompositesFactory repositoryCompositesFactory = repositoryCompositesPackage.getRepositoryCompositesFactory(); /** * This is the file creation page. @@ -135,7 +135,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * <!-- end-user-doc --> * @generated */ - protected RepositoryModelWizardNewFileCreationPage newFileCreationPage; + protected RepositoryCompositesModelWizardNewFileCreationPage newFileCreationPage; /** * This is the initial object creation page. @@ -143,7 +143,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * <!-- end-user-doc --> * @generated */ - protected RepositoryModelWizardInitialObjectCreationPage initialObjectCreationPage; + protected RepositoryCompositesModelWizardInitialObjectCreationPage initialObjectCreationPage; /** * Remember the selection during initialization for populating the default container. @@ -179,7 +179,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { this.workbench = workbench; this.selection = selection; setWindowTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_label")); - setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(ApplicationlevelEditorPlugin.INSTANCE.getImage("full/wizban/NewRepository"))); + setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(ApplicationlevelEditorPlugin.INSTANCE.getImage("full/wizban/NewRepositoryComposites"))); } /** @@ -191,7 +191,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { protected Collection<String> getInitialObjectNames() { if (initialObjectNames == null) { initialObjectNames = new ArrayList<String>(); - for (EClassifier eClassifier : repositoryPackage.getEClassifiers()) { + for (EClassifier eClassifier : repositoryCompositesPackage.getEClassifiers()) { if (eClassifier instanceof EClass) { EClass eClass = (EClass)eClassifier; if (!eClass.isAbstract()) { @@ -211,8 +211,8 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * @generated */ protected EObject createInitialModel() { - EClass eClass = (EClass)repositoryPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName()); - EObject rootObject = repositoryFactory.create(eClass); + EClass eClass = (EClass)repositoryCompositesPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName()); + EObject rootObject = repositoryCompositesFactory.create(eClass); return rootObject; } @@ -313,14 +313,14 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * <!-- end-user-doc --> * @generated */ - public class RepositoryModelWizardNewFileCreationPage extends WizardNewFileCreationPage { + public class RepositoryCompositesModelWizardNewFileCreationPage extends WizardNewFileCreationPage { /** * Pass in the selection. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ - public RepositoryModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) { + public RepositoryCompositesModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) { super(pageId, selection); } @@ -360,7 +360,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * <!-- end-user-doc --> * @generated */ - public class RepositoryModelWizardInitialObjectCreationPage extends WizardPage { + public class RepositoryCompositesModelWizardInitialObjectCreationPage extends WizardPage { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -388,7 +388,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * <!-- end-user-doc --> * @generated */ - public RepositoryModelWizardInitialObjectCreationPage(String pageId) { + public RepositoryCompositesModelWizardInitialObjectCreationPage(String pageId) { super(pageId); } @@ -398,7 +398,8 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { * @generated */ public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); { + Composite composite = new Composite(parent, SWT.NONE); + { GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.verticalSpacing = 12; @@ -572,10 +573,10 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { public void addPages() { // Create a page, set the title, and the initial model file name. // - newFileCreationPage = new RepositoryModelWizardNewFileCreationPage("Whatever", selection); - newFileCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryModelWizard_label")); - newFileCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryModelWizard_description")); - newFileCreationPage.setFileName(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); + newFileCreationPage = new RepositoryCompositesModelWizardNewFileCreationPage("Whatever", selection); + newFileCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryCompositesModelWizard_label")); + newFileCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryCompositesModelWizard_description")); + newFileCreationPage.setFileName(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryCompositesEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); addPage(newFileCreationPage); // Try and get the resource selection to determine a current directory for the file dialog. @@ -601,7 +602,7 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { // Make up a unique new name here. // - String defaultModelBaseFilename = ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryEditorFilenameDefaultBase"); + String defaultModelBaseFilename = ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryCompositesEditorFilenameDefaultBase"); String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0); String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) { @@ -611,8 +612,8 @@ public class RepositoryModelWizard extends Wizard implements INewWizard { } } } - initialObjectCreationPage = new RepositoryModelWizardInitialObjectCreationPage("Whatever2"); - initialObjectCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryModelWizard_label")); + initialObjectCreationPage = new RepositoryCompositesModelWizardInitialObjectCreationPage("Whatever2"); + initialObjectCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RepositoryCompositesModelWizard_label")); initialObjectCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description")); addPage(initialObjectCreationPage); } diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorEditor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorEditor.java deleted file mode 100644 index d1a8fa2a..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorEditor.java +++ /dev/null @@ -1,1839 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.servicebehavior.presentation; - - -import java.io.IOException; -import java.io.InputStream; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EventObject; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; - -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.swt.SWT; - -import org.eclipse.swt.custom.CTabFolder; - -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.Transfer; - -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; - -import org.eclipse.swt.graphics.Point; - -import org.eclipse.swt.layout.FillLayout; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; - -import org.eclipse.ui.dialogs.SaveAsDialog; - -import org.eclipse.ui.ide.IGotoMarker; - -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.MultiPageEditorPart; - -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheet; -import org.eclipse.ui.views.properties.PropertySheetPage; - -import org.eclipse.emf.common.command.BasicCommandStack; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.common.command.CommandStackListener; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.common.ui.MarkerHelper; -import org.eclipse.emf.common.ui.ViewerPane; - -import org.eclipse.emf.common.ui.editor.ProblemEditorPart; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EValidator; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.emf.ecore.util.EcoreUtil; - -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; - -import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; - -import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; - -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; - -import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; - -import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; -import org.eclipse.emf.edit.ui.dnd.LocalTransfer; -import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; - -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider; - -import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper; -import org.eclipse.emf.edit.ui.util.EditUIUtil; - -import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; - -import edu.kit.ipd.descartes.mm.servicebehavior.provider.ServicebehaviorItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.identifier.provider.IdentifierItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import edu.kit.ipd.descartes.mm.core.provider.CoreItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.functions.provider.FunctionsItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.parameterdependencies.provider.ParameterdependenciesItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.repository.provider.RepositoryItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.resourceconfiguration.provider.ResourceconfigurationItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.system.provider.SystemItemProviderAdapterFactory; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - - -/** - * This is an example of a Servicebehavior model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class ServicebehaviorEditor - extends MultiPageEditorPart - implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker { - /** - * This keeps track of the editing domain that is used to track all changes to the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected AdapterFactoryEditingDomain editingDomain; - - /** - * This is the one adapter factory used for providing views of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ComposedAdapterFactory adapterFactory; - - /** - * This is the content outline page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IContentOutlinePage contentOutlinePage; - - /** - * This is a kludge... - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IStatusLineManager contentOutlineStatusLineManager; - - /** - * This is the content outline page's viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer contentOutlineViewer; - - /** - * This is the property sheet page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected PropertySheetPage propertySheetPage; - - /** - * This is the viewer that shadows the selection in the content outline. - * The parent relation must be correctly defined for this to work. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer selectionViewer; - - /** - * This inverts the roll of parent and child in the content provider and show parents as a tree. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer parentViewer; - - /** - * This shows how a tree view works. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer treeViewer; - - /** - * This shows how a list view works. - * A list viewer doesn't support icons. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ListViewer listViewer; - - /** - * This shows how a table view works. - * A table can be used as a list with icons. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TableViewer tableViewer; - - /** - * This shows how a tree view with columns works. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer treeViewerWithColumns; - - /** - * This keeps track of the active viewer pane, in the book. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ViewerPane currentViewerPane; - - /** - * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Viewer currentViewer; - - /** - * This listens to which ever viewer is active. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelectionChangedListener selectionChangedListener; - - /** - * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); - - /** - * This keeps track of the selection of the editor as a whole. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelection editorSelection = StructuredSelection.EMPTY; - - /** - * The MarkerHelper is responsible for creating workspace resource markers presented - * in Eclipse's Problems View. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected MarkerHelper markerHelper = new EditUIMarkerHelper(); - - /** - * This listens for when the outline becomes active - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IPartListener partListener = - new IPartListener() { - public void partActivated(IWorkbenchPart p) { - if (p instanceof ContentOutline) { - if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) { - getActionBarContributor().setActiveEditor(ServicebehaviorEditor.this); - - setCurrentViewer(contentOutlineViewer); - } - } - else if (p instanceof PropertySheet) { - if (((PropertySheet)p).getCurrentPage() == propertySheetPage) { - getActionBarContributor().setActiveEditor(ServicebehaviorEditor.this); - handleActivate(); - } - } - else if (p == ServicebehaviorEditor.this) { - handleActivate(); - } - } - public void partBroughtToTop(IWorkbenchPart p) { - // Ignore. - } - public void partClosed(IWorkbenchPart p) { - // Ignore. - } - public void partDeactivated(IWorkbenchPart p) { - // Ignore. - } - public void partOpened(IWorkbenchPart p) { - // Ignore. - } - }; - - /** - * Resources that have been removed since last activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> removedResources = new ArrayList<Resource>(); - - /** - * Resources that have been changed since last activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> changedResources = new ArrayList<Resource>(); - - /** - * Resources that have been saved. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> savedResources = new ArrayList<Resource>(); - - /** - * Map to store the diagnostic associated with a resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>(); - - /** - * Controls whether the problem indication should be updated. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean updateProblemIndication = true; - - /** - * Adapter used to update the problem indication when resources are demanded loaded. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EContentAdapter problemIndicationAdapter = - new EContentAdapter() { - @Override - public void notifyChanged(Notification notification) { - if (notification.getNotifier() instanceof Resource) { - switch (notification.getFeatureID(Resource.class)) { - case Resource.RESOURCE__IS_LOADED: - case Resource.RESOURCE__ERRORS: - case Resource.RESOURCE__WARNINGS: { - Resource resource = (Resource)notification.getNotifier(); - Diagnostic diagnostic = analyzeResourceProblems(resource, null); - if (diagnostic.getSeverity() != Diagnostic.OK) { - resourceToDiagnosticMap.put(resource, diagnostic); - } - else { - resourceToDiagnosticMap.remove(resource); - } - - if (updateProblemIndication) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - updateProblemIndication(); - } - }); - } - break; - } - } - } - else { - super.notifyChanged(notification); - } - } - - @Override - protected void setTarget(Resource target) { - basicSetTarget(target); - } - - @Override - protected void unsetTarget(Resource target) { - basicUnsetTarget(target); - } - }; - - /** - * This listens for workspace changes. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IResourceChangeListener resourceChangeListener = - new IResourceChangeListener() { - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - try { - class ResourceDeltaVisitor implements IResourceDeltaVisitor { - protected ResourceSet resourceSet = editingDomain.getResourceSet(); - protected Collection<Resource> changedResources = new ArrayList<Resource>(); - protected Collection<Resource> removedResources = new ArrayList<Resource>(); - - public boolean visit(IResourceDelta delta) { - if (delta.getResource().getType() == IResource.FILE) { - if (delta.getKind() == IResourceDelta.REMOVED || - delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) { - Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false); - if (resource != null) { - if (delta.getKind() == IResourceDelta.REMOVED) { - removedResources.add(resource); - } - else if (!savedResources.remove(resource)) { - changedResources.add(resource); - } - } - } - } - - return true; - } - - public Collection<Resource> getChangedResources() { - return changedResources; - } - - public Collection<Resource> getRemovedResources() { - return removedResources; - } - } - - final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - delta.accept(visitor); - - if (!visitor.getRemovedResources().isEmpty()) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - removedResources.addAll(visitor.getRemovedResources()); - if (!isDirty()) { - getSite().getPage().closeEditor(ServicebehaviorEditor.this, false); - } - } - }); - } - - if (!visitor.getChangedResources().isEmpty()) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - changedResources.addAll(visitor.getChangedResources()); - if (getSite().getPage().getActiveEditor() == ServicebehaviorEditor.this) { - handleActivate(); - } - } - }); - } - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - }; - - /** - * Handles activation of the editor or it's associated views. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void handleActivate() { - // Recompute the read only state. - // - if (editingDomain.getResourceToReadOnlyMap() != null) { - editingDomain.getResourceToReadOnlyMap().clear(); - - // Refresh any actions that may become enabled or disabled. - // - setSelection(getSelection()); - } - - if (!removedResources.isEmpty()) { - if (handleDirtyConflict()) { - getSite().getPage().closeEditor(ServicebehaviorEditor.this, false); - } - else { - removedResources.clear(); - changedResources.clear(); - savedResources.clear(); - } - } - else if (!changedResources.isEmpty()) { - changedResources.removeAll(savedResources); - handleChangedResources(); - changedResources.clear(); - savedResources.clear(); - } - } - - /** - * Handles what to do with changed resources on activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void handleChangedResources() { - if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) { - if (isDirty()) { - changedResources.addAll(editingDomain.getResourceSet().getResources()); - } - editingDomain.getCommandStack().flush(); - - updateProblemIndication = false; - for (Resource resource : changedResources) { - if (resource.isLoaded()) { - resource.unload(); - try { - resource.load(Collections.EMPTY_MAP); - } - catch (IOException exception) { - if (!resourceToDiagnosticMap.containsKey(resource)) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - } - } - } - - if (AdapterFactoryEditingDomain.isStale(editorSelection)) { - setSelection(StructuredSelection.EMPTY); - } - - updateProblemIndication = true; - updateProblemIndication(); - } - } - - /** - * Updates the problems indication with the information described in the specified diagnostic. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void updateProblemIndication() { - if (updateProblemIndication) { - BasicDiagnostic diagnostic = - new BasicDiagnostic - (Diagnostic.OK, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - null, - new Object [] { editingDomain.getResourceSet() }); - for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) { - if (childDiagnostic.getSeverity() != Diagnostic.OK) { - diagnostic.add(childDiagnostic); - } - } - - int lastEditorPage = getPageCount() - 1; - if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) { - ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic); - if (diagnostic.getSeverity() != Diagnostic.OK) { - setActivePage(lastEditorPage); - } - } - else if (diagnostic.getSeverity() != Diagnostic.OK) { - ProblemEditorPart problemEditorPart = new ProblemEditorPart(); - problemEditorPart.setDiagnostic(diagnostic); - problemEditorPart.setMarkerHelper(markerHelper); - try { - addPage(++lastEditorPage, problemEditorPart, getEditorInput()); - setPageText(lastEditorPage, problemEditorPart.getPartName()); - setActivePage(lastEditorPage); - showTabs(); - } - catch (PartInitException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - - if (markerHelper.hasMarkers(editingDomain.getResourceSet())) { - markerHelper.deleteMarkers(editingDomain.getResourceSet()); - if (diagnostic.getSeverity() != Diagnostic.OK) { - try { - markerHelper.createMarkers(diagnostic); - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - } - } - } - - /** - * Shows a dialog that asks if conflicting changes should be discarded. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean handleDirtyConflict() { - return - MessageDialog.openQuestion - (getSite().getShell(), - getString("_UI_FileConflict_label"), - getString("_WARN_FileConflict")); - } - - /** - * This creates a model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ServicebehaviorEditor() { - super(); - initializeEditingDomain(); - } - - /** - * This sets up the editing domain for the model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void initializeEditingDomain() { - // Create an adapter factory that yields item providers. - // - adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - - adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new RepositoryItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ServicebehaviorItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new SystemItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ParameterdependenciesItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new FunctionsItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new CoreItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new IdentifierItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ResourceconfigurationItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ResourcetypeItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); - - // Create the command stack that will notify this editor as commands are executed. - // - BasicCommandStack commandStack = new BasicCommandStack(); - - // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. - // - commandStack.addCommandStackListener - (new CommandStackListener() { - public void commandStackChanged(final EventObject event) { - getContainer().getDisplay().asyncExec - (new Runnable() { - public void run() { - firePropertyChange(IEditorPart.PROP_DIRTY); - - // Try to select the affected objects. - // - Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); - if (mostRecentCommand != null) { - setSelectionToViewer(mostRecentCommand.getAffectedObjects()); - } - if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) { - propertySheetPage.refresh(); - } - } - }); - } - }); - - // Create the editing domain with a special command stack. - // - editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>()); - } - - /** - * This is here for the listener to be able to call it. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void firePropertyChange(int action) { - super.firePropertyChange(action); - } - - /** - * This sets the selection into whichever viewer is active. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSelectionToViewer(Collection<?> collection) { - final Collection<?> theSelection = collection; - // Make sure it's okay. - // - if (theSelection != null && !theSelection.isEmpty()) { - Runnable runnable = - new Runnable() { - public void run() { - // Try to select the items in the current content viewer of the editor. - // - if (currentViewer != null) { - currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); - } - } - }; - getSite().getShell().getDisplay().asyncExec(runnable); - } - } - - /** - * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. - * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} - * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EditingDomain getEditingDomain() { - return editingDomain; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object [] getElements(Object object) { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object [] getChildren(Object object) { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean hasChildren(Object object) { - Object parent = super.getParent(object); - return parent != null; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object getParent(Object object) { - return null; - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCurrentViewerPane(ViewerPane viewerPane) { - if (currentViewerPane != viewerPane) { - if (currentViewerPane != null) { - currentViewerPane.showFocus(false); - } - currentViewerPane = viewerPane; - } - setCurrentViewer(currentViewerPane.getViewer()); - } - - /** - * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, - * is the current one. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCurrentViewer(Viewer viewer) { - // If it is changing... - // - if (currentViewer != viewer) { - if (selectionChangedListener == null) { - // Create the listener on demand. - // - selectionChangedListener = - new ISelectionChangedListener() { - // This just notifies those things that are affected by the section. - // - public void selectionChanged(SelectionChangedEvent selectionChangedEvent) { - setSelection(selectionChangedEvent.getSelection()); - } - }; - } - - // Stop listening to the old one. - // - if (currentViewer != null) { - currentViewer.removeSelectionChangedListener(selectionChangedListener); - } - - // Start listening to the new one. - // - if (viewer != null) { - viewer.addSelectionChangedListener(selectionChangedListener); - } - - // Remember it. - // - currentViewer = viewer; - - // Set the editors selection based on the current viewer's selection. - // - setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); - } - } - - /** - * This returns the viewer as required by the {@link IViewerProvider} interface. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Viewer getViewer() { - return currentViewer; - } - - /** - * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createContextMenuFor(StructuredViewer viewer) { - MenuManager contextMenu = new MenuManager("#PopUp"); - contextMenu.add(new Separator("additions")); - contextMenu.setRemoveAllWhenShown(true); - contextMenu.addMenuListener(this); - Menu menu= contextMenu.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); - - int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; - Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() }; - viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); - viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); - } - - /** - * This is the method called to load a resource into the editing domain's resource set based on the editor's input. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createModel() { - URI resourceURI = EditUIUtil.getURI(getEditorInput()); - Exception exception = null; - Resource resource = null; - try { - // Load the resource through the editing domain. - // - resource = editingDomain.getResourceSet().getResource(resourceURI, true); - } - catch (Exception e) { - exception = e; - resource = editingDomain.getResourceSet().getResource(resourceURI, false); - } - - Diagnostic diagnostic = analyzeResourceProblems(resource, exception); - if (diagnostic.getSeverity() != Diagnostic.OK) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); - } - - /** - * Returns a diagnostic describing the errors and warnings listed in the resource - * and the specified exception (if any). - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) { - if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) { - BasicDiagnostic basicDiagnostic = - new BasicDiagnostic - (Diagnostic.ERROR, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object [] { exception == null ? (Object)resource : exception }); - basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); - return basicDiagnostic; - } - else if (exception != null) { - return - new BasicDiagnostic - (Diagnostic.ERROR, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object[] { exception }); - } - else { - return Diagnostic.OK_INSTANCE; - } - } - - /** - * This is the method used by the framework to install your own controls. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void createPages() { - // Creates the model from the editor input - // - createModel(); - - // Only creates the other pages if there is something that can be edited - // - if (!getEditingDomain().getResourceSet().getResources().isEmpty()) { - // Create a page for the selection tree view. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ServicebehaviorEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - Tree tree = new Tree(composite, SWT.MULTI); - TreeViewer newTreeViewer = new TreeViewer(tree); - return newTreeViewer; - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - selectionViewer = (TreeViewer)viewerPane.getViewer(); - selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - - selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - selectionViewer.setInput(editingDomain.getResourceSet()); - selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - viewerPane.setTitle(editingDomain.getResourceSet()); - - new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); - - createContextMenuFor(selectionViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_SelectionPage_label")); - } - - // Create a page for the parent tree view. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ServicebehaviorEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - Tree tree = new Tree(composite, SWT.MULTI); - TreeViewer newTreeViewer = new TreeViewer(tree); - return newTreeViewer; - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - parentViewer = (TreeViewer)viewerPane.getViewer(); - parentViewer.setAutoExpandLevel(30); - parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory)); - parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(parentViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_ParentPage_label")); - } - - // This is the page for the list viewer - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ServicebehaviorEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new ListViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - listViewer = (ListViewer)viewerPane.getViewer(); - listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(listViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_ListPage_label")); - } - - // This is the page for the tree viewer - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ServicebehaviorEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TreeViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - treeViewer = (TreeViewer)viewerPane.getViewer(); - treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); - - createContextMenuFor(treeViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TreePage_label")); - } - - // This is the page for the table viewer. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ServicebehaviorEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TableViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - tableViewer = (TableViewer)viewerPane.getViewer(); - - Table table = tableViewer.getTable(); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - TableColumn objectColumn = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(3, 100, true)); - objectColumn.setText(getString("_UI_ObjectColumn_label")); - objectColumn.setResizable(true); - - TableColumn selfColumn = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(2, 100, true)); - selfColumn.setText(getString("_UI_SelfColumn_label")); - selfColumn.setResizable(true); - - tableViewer.setColumnProperties(new String [] {"a", "b"}); - tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(tableViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TablePage_label")); - } - - // This is the page for the table tree viewer. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), ServicebehaviorEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TreeViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - treeViewerWithColumns = (TreeViewer)viewerPane.getViewer(); - - Tree tree = treeViewerWithColumns.getTree(); - tree.setLayoutData(new FillLayout()); - tree.setHeaderVisible(true); - tree.setLinesVisible(true); - - TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE); - objectColumn.setText(getString("_UI_ObjectColumn_label")); - objectColumn.setResizable(true); - objectColumn.setWidth(250); - - TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE); - selfColumn.setText(getString("_UI_SelfColumn_label")); - selfColumn.setResizable(true); - selfColumn.setWidth(200); - - treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"}); - treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(treeViewerWithColumns); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); - } - - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - setActivePage(0); - } - }); - } - - // Ensures that this editor will only display the page's tab - // area if there are more than one page - // - getContainer().addControlListener - (new ControlAdapter() { - boolean guard = false; - @Override - public void controlResized(ControlEvent event) { - if (!guard) { - guard = true; - hideTabs(); - guard = false; - } - } - }); - - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - updateProblemIndication(); - } - }); - } - - /** - * If there is just one page in the multi-page editor part, - * this hides the single tab at the bottom. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void hideTabs() { - if (getPageCount() <= 1) { - setPageText(0, ""); - if (getContainer() instanceof CTabFolder) { - ((CTabFolder)getContainer()).setTabHeight(1); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y + 6); - } - } - } - - /** - * If there is more than one page in the multi-page editor part, - * this shows the tabs at the bottom. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void showTabs() { - if (getPageCount() > 1) { - setPageText(0, getString("_UI_SelectionPage_label")); - if (getContainer() instanceof CTabFolder) { - ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y - 6); - } - } - } - - /** - * This is used to track the active viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void pageChange(int pageIndex) { - super.pageChange(pageIndex); - - if (contentOutlinePage != null) { - handleContentOutlineSelection(contentOutlinePage.getSelection()); - } - } - - /** - * This is how the framework determines which interfaces we implement. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class key) { - if (key.equals(IContentOutlinePage.class)) { - return showOutlineView() ? getContentOutlinePage() : null; - } - else if (key.equals(IPropertySheetPage.class)) { - return getPropertySheetPage(); - } - else if (key.equals(IGotoMarker.class)) { - return this; - } - else { - return super.getAdapter(key); - } - } - - /** - * This accesses a cached version of the content outliner. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IContentOutlinePage getContentOutlinePage() { - if (contentOutlinePage == null) { - // The content outline is just a tree. - // - class MyContentOutlinePage extends ContentOutlinePage { - @Override - public void createControl(Composite parent) { - super.createControl(parent); - contentOutlineViewer = getTreeViewer(); - contentOutlineViewer.addSelectionChangedListener(this); - - // Set up the tree viewer. - // - contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - contentOutlineViewer.setInput(editingDomain.getResourceSet()); - - // Make sure our popups work. - // - createContextMenuFor(contentOutlineViewer); - - if (!editingDomain.getResourceSet().getResources().isEmpty()) { - // Select the root object in the view. - // - contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - } - } - - @Override - public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { - super.makeContributions(menuManager, toolBarManager, statusLineManager); - contentOutlineStatusLineManager = statusLineManager; - } - - @Override - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - } - - contentOutlinePage = new MyContentOutlinePage(); - - // Listen to selection so that we can handle it is a special way. - // - contentOutlinePage.addSelectionChangedListener - (new ISelectionChangedListener() { - // This ensures that we handle selections correctly. - // - public void selectionChanged(SelectionChangedEvent event) { - handleContentOutlineSelection(event.getSelection()); - } - }); - } - - return contentOutlinePage; - } - - /** - * This accesses a cached version of the property sheet. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IPropertySheetPage getPropertySheetPage() { - if (propertySheetPage == null) { - propertySheetPage = - new ExtendedPropertySheetPage(editingDomain) { - @Override - public void setSelectionToViewer(List<?> selection) { - ServicebehaviorEditor.this.setSelectionToViewer(selection); - ServicebehaviorEditor.this.setFocus(); - } - - @Override - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - }; - propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); - } - - return propertySheetPage; - } - - /** - * This deals with how we want selection in the outliner to affect the other views. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void handleContentOutlineSelection(ISelection selection) { - if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { - Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator(); - if (selectedElements.hasNext()) { - // Get the first selected element. - // - Object selectedElement = selectedElements.next(); - - // If it's the selection viewer, then we want it to select the same selection as this selection. - // - if (currentViewerPane.getViewer() == selectionViewer) { - ArrayList<Object> selectionList = new ArrayList<Object>(); - selectionList.add(selectedElement); - while (selectedElements.hasNext()) { - selectionList.add(selectedElements.next()); - } - - // Set the selection to the widget. - // - selectionViewer.setSelection(new StructuredSelection(selectionList)); - } - else { - // Set the input to the widget. - // - if (currentViewerPane.getViewer().getInput() != selectedElement) { - currentViewerPane.getViewer().setInput(selectedElement); - currentViewerPane.setTitle(selectedElement); - } - } - } - } - } - - /** - * This is for implementing {@link IEditorPart} and simply tests the command stack. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean isDirty() { - return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded(); - } - - /** - * This is for implementing {@link IEditorPart} and simply saves the model file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void doSave(IProgressMonitor progressMonitor) { - // Save only resources that have actually changed. - // - final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); - saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); - - // Do the work within an operation because this is a long running activity that modifies the workbench. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - // This is the method that gets invoked when the operation runs. - // - @Override - public void execute(IProgressMonitor monitor) { - // Save the resources to the file system. - // - boolean first = true; - for (Resource resource : editingDomain.getResourceSet().getResources()) { - if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { - try { - long timeStamp = resource.getTimeStamp(); - resource.save(saveOptions); - if (resource.getTimeStamp() != timeStamp) { - savedResources.add(resource); - } - } - catch (Exception exception) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - first = false; - } - } - } - }; - - updateProblemIndication = false; - try { - // This runs the options, and shows progress. - // - new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); - - // Refresh the necessary state. - // - ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); - firePropertyChange(IEditorPart.PROP_DIRTY); - } - catch (Exception exception) { - // Something went wrong that shouldn't. - // - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - updateProblemIndication = true; - updateProblemIndication(); - } - - /** - * This returns whether something has been persisted to the URI of the specified resource. - * The implementation uses the URI converter from the editor's resource set to try to open an input stream. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean isPersisted(Resource resource) { - boolean result = false; - try { - InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); - if (stream != null) { - result = true; - stream.close(); - } - } - catch (IOException e) { - // Ignore - } - return result; - } - - /** - * This always returns true because it is not currently supported. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean isSaveAsAllowed() { - return true; - } - - /** - * This also changes the editor's input. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void doSaveAs() { - SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); - saveAsDialog.open(); - IPath path = saveAsDialog.getResult(); - if (path != null) { - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - if (file != null) { - doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void doSaveAs(URI uri, IEditorInput editorInput) { - (editingDomain.getResourceSet().getResources().get(0)).setURI(uri); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - IProgressMonitor progressMonitor = - getActionBars().getStatusLineManager() != null ? - getActionBars().getStatusLineManager().getProgressMonitor() : - new NullProgressMonitor(); - doSave(progressMonitor); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void gotoMarker(IMarker marker) { - try { - if (marker.getType().equals(EValidator.MARKER)) { - String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null); - if (uriAttribute != null) { - URI uri = URI.createURI(uriAttribute); - EObject eObject = editingDomain.getResourceSet().getEObject(uri, true); - if (eObject != null) { - setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject))); - } - } - } - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - - /** - * This is called during startup. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void init(IEditorSite site, IEditorInput editorInput) { - setSite(site); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - site.setSelectionProvider(this); - site.getPage().addPartListener(partListener); - ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setFocus() { - if (currentViewerPane != null) { - currentViewerPane.setFocus(); - } - else { - getControl(getActivePage()).setFocus(); - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ISelection getSelection() { - return editorSelection; - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. - * Calling this result will notify the listeners. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSelection(ISelection selection) { - editorSelection = selection; - - for (ISelectionChangedListener listener : selectionChangedListeners) { - listener.selectionChanged(new SelectionChangedEvent(this, selection)); - } - setStatusLineManager(selection); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setStatusLineManager(ISelection selection) { - IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? - contentOutlineStatusLineManager : getActionBars().getStatusLineManager(); - - if (statusLineManager != null) { - if (selection instanceof IStructuredSelection) { - Collection<?> collection = ((IStructuredSelection)selection).toList(); - switch (collection.size()) { - case 0: { - statusLineManager.setMessage(getString("_UI_NoObjectSelected")); - break; - } - case 1: { - String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next()); - statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); - break; - } - default: { - statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size()))); - break; - } - } - } - else { - statusLineManager.setMessage(""); - } - } - } - - /** - * This looks up a string in the plugin's plugin.properties file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static String getString(String key) { - return ApplicationlevelEditorPlugin.INSTANCE.getString(key); - } - - /** - * This looks up a string in plugin.properties, making a substitution. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static String getString(String key, Object s1) { - return ApplicationlevelEditorPlugin.INSTANCE.getString(key, new Object [] { s1 }); - } - - /** - * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void menuAboutToShow(IMenuManager menuManager) { - ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EditingDomainActionBarContributor getActionBarContributor() { - return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IActionBars getActionBars() { - return getActionBarContributor().getActionBars(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public AdapterFactory getAdapterFactory() { - return adapterFactory; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void dispose() { - updateProblemIndication = false; - - ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); - - getSite().getPage().removePartListener(partListener); - - adapterFactory.dispose(); - - if (getActionBarContributor().getActiveEditor() == this) { - getActionBarContributor().setActiveEditor(null); - } - - if (propertySheetPage != null) { - propertySheetPage.dispose(); - } - - if (contentOutlinePage != null) { - contentOutlinePage.dispose(); - } - - super.dispose(); - } - - /** - * Returns whether the outline view should be presented to the user. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean showOutlineView() { - return true; - } -} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorModelWizard.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorModelWizard.java deleted file mode 100644 index 10fc0818..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/servicebehavior/presentation/ServicebehaviorModelWizard.java +++ /dev/null @@ -1,630 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.servicebehavior.presentation; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.StringTokenizer; - -import org.eclipse.emf.common.CommonPlugin; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.jface.dialogs.MessageDialog; - -import org.eclipse.jface.viewers.IStructuredSelection; - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; - -import org.eclipse.swt.SWT; - -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.ModifyEvent; - -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; - -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; - -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; - -import edu.kit.ipd.descartes.mm.servicebehavior.ServicebehaviorFactory; -import edu.kit.ipd.descartes.mm.servicebehavior.ServicebehaviorPackage; -import edu.kit.ipd.descartes.mm.applicationlevel.provider.ApplicationlevelEditPlugin; - - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import org.eclipse.core.runtime.Path; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; - -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; - - -/** - * This is a simple wizard for creating a new model file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class ServicebehaviorModelWizard extends Wizard implements INewWizard { - /** - * The supported extensions for created files. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final List<String> FILE_EXTENSIONS = - Collections.unmodifiableList(Arrays.asList(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ServicebehaviorEditorFilenameExtensions").split("\\s*,\\s*"))); - - /** - * A formatted list of supported file extensions, suitable for display. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String FORMATTED_FILE_EXTENSIONS = - ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ServicebehaviorEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); - - /** - * This caches an instance of the model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ServicebehaviorPackage servicebehaviorPackage = ServicebehaviorPackage.eINSTANCE; - - /** - * This caches an instance of the model factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ServicebehaviorFactory servicebehaviorFactory = servicebehaviorPackage.getServicebehaviorFactory(); - - /** - * This is the file creation page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ServicebehaviorModelWizardNewFileCreationPage newFileCreationPage; - - /** - * This is the initial object creation page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ServicebehaviorModelWizardInitialObjectCreationPage initialObjectCreationPage; - - /** - * Remember the selection during initialization for populating the default container. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IStructuredSelection selection; - - /** - * Remember the workbench during initialization. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IWorkbench workbench; - - /** - * Caches the names of the types that can be created as the root object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected List<String> initialObjectNames; - - /** - * This just records the information. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.workbench = workbench; - this.selection = selection; - setWindowTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_label")); - setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(ApplicationlevelEditorPlugin.INSTANCE.getImage("full/wizban/NewServicebehavior"))); - } - - /** - * Returns the names of the types that can be created as the root object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<String> getInitialObjectNames() { - if (initialObjectNames == null) { - initialObjectNames = new ArrayList<String>(); - for (EClassifier eClassifier : servicebehaviorPackage.getEClassifiers()) { - if (eClassifier instanceof EClass) { - EClass eClass = (EClass)eClassifier; - if (!eClass.isAbstract()) { - initialObjectNames.add(eClass.getName()); - } - } - } - Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator()); - } - return initialObjectNames; - } - - /** - * Create a new model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EObject createInitialModel() { - EClass eClass = (EClass)servicebehaviorPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName()); - EObject rootObject = servicebehaviorFactory.create(eClass); - return rootObject; - } - - /** - * Do the work after everything is specified. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean performFinish() { - try { - // Remember the file. - // - final IFile modelFile = getModelFile(); - - // Do the work within an operation. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - @Override - protected void execute(IProgressMonitor progressMonitor) { - try { - // Create a resource set - // - ResourceSet resourceSet = new ResourceSetImpl(); - - // Get the URI of the model file. - // - URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true); - - // Create a resource for this file. - // - Resource resource = resourceSet.createResource(fileURI); - - // Add the initial model object to the contents. - // - EObject rootObject = createInitialModel(); - if (rootObject != null) { - resource.getContents().add(rootObject); - } - - // Save the contents of the resource to the file system. - // - Map<Object, Object> options = new HashMap<Object, Object>(); - options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding()); - resource.save(options); - } - catch (Exception exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - finally { - progressMonitor.done(); - } - } - }; - - getContainer().run(false, false, operation); - - // Select the new file resource in the current view. - // - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IWorkbenchPage page = workbenchWindow.getActivePage(); - final IWorkbenchPart activePart = page.getActivePart(); - if (activePart instanceof ISetSelectionTarget) { - final ISelection targetSelection = new StructuredSelection(modelFile); - getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - ((ISetSelectionTarget)activePart).selectReveal(targetSelection); - } - }); - } - - // Open an editor on the new file. - // - try { - page.openEditor - (new FileEditorInput(modelFile), - workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId()); - } - catch (PartInitException exception) { - MessageDialog.openError(workbenchWindow.getShell(), ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); - return false; - } - - return true; - } - catch (Exception exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - return false; - } - } - - /** - * This is the one page of the wizard. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class ServicebehaviorModelWizardNewFileCreationPage extends WizardNewFileCreationPage { - /** - * Pass in the selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ServicebehaviorModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) { - super(pageId, selection); - } - - /** - * The framework calls this to see if the file is correct. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected boolean validatePage() { - if (super.validatePage()) { - String extension = new Path(getFileName()).getFileExtension(); - if (extension == null || !FILE_EXTENSIONS.contains(extension)) { - String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; - setErrorMessage(ApplicationlevelEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS })); - return false; - } - return true; - } - return false; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IFile getModelFile() { - return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName())); - } - } - - /** - * This is the page where the type of object to create is selected. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class ServicebehaviorModelWizardInitialObjectCreationPage extends WizardPage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Combo initialObjectField; - - /** - * @generated - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - */ - protected List<String> encodings; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Combo encodingField; - - /** - * Pass in the selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ServicebehaviorModelWizardInitialObjectCreationPage(String pageId) { - super(pageId); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); { - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.verticalSpacing = 12; - composite.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - } - - Label containerLabel = new Label(composite, SWT.LEFT); - { - containerLabel.setText(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ModelObject")); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - containerLabel.setLayoutData(data); - } - - initialObjectField = new Combo(composite, SWT.BORDER); - { - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - initialObjectField.setLayoutData(data); - } - - for (String objectName : getInitialObjectNames()) { - initialObjectField.add(getLabel(objectName)); - } - - if (initialObjectField.getItemCount() == 1) { - initialObjectField.select(0); - } - initialObjectField.addModifyListener(validator); - - Label encodingLabel = new Label(composite, SWT.LEFT); - { - encodingLabel.setText(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_XMLEncoding")); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - encodingLabel.setLayoutData(data); - } - encodingField = new Combo(composite, SWT.BORDER); - { - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - encodingField.setLayoutData(data); - } - - for (String encoding : getEncodings()) { - encodingField.add(encoding); - } - - encodingField.select(0); - encodingField.addModifyListener(validator); - - setPageComplete(validatePage()); - setControl(composite); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ModifyListener validator = - new ModifyListener() { - public void modifyText(ModifyEvent e) { - setPageComplete(validatePage()); - } - }; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean validatePage() { - return getInitialObjectName() != null && getEncodings().contains(encodingField.getText()); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - if (initialObjectField.getItemCount() == 1) { - initialObjectField.clearSelection(); - encodingField.setFocus(); - } - else { - encodingField.clearSelection(); - initialObjectField.setFocus(); - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getInitialObjectName() { - String label = initialObjectField.getText(); - - for (String name : getInitialObjectNames()) { - if (getLabel(name).equals(label)) { - return name; - } - } - return null; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getEncoding() { - return encodingField.getText(); - } - - /** - * Returns the label for the specified type name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected String getLabel(String typeName) { - try { - return ApplicationlevelEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); - } - catch(MissingResourceException mre) { - ApplicationlevelEditorPlugin.INSTANCE.log(mre); - } - return typeName; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<String> getEncodings() { - if (encodings == null) { - encodings = new ArrayList<String>(); - for (StringTokenizer stringTokenizer = new StringTokenizer(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) { - encodings.add(stringTokenizer.nextToken()); - } - } - return encodings; - } - } - - /** - * The framework calls this to create the contents of the wizard. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void addPages() { - // Create a page, set the title, and the initial model file name. - // - newFileCreationPage = new ServicebehaviorModelWizardNewFileCreationPage("Whatever", selection); - newFileCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ServicebehaviorModelWizard_label")); - newFileCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ServicebehaviorModelWizard_description")); - newFileCreationPage.setFileName(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ServicebehaviorEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); - addPage(newFileCreationPage); - - // Try and get the resource selection to determine a current directory for the file dialog. - // - if (selection != null && !selection.isEmpty()) { - // Get the resource... - // - Object selectedElement = selection.iterator().next(); - if (selectedElement instanceof IResource) { - // Get the resource parent, if its a file. - // - IResource selectedResource = (IResource)selectedElement; - if (selectedResource.getType() == IResource.FILE) { - selectedResource = selectedResource.getParent(); - } - - // This gives us a directory... - // - if (selectedResource instanceof IFolder || selectedResource instanceof IProject) { - // Set this for the container. - // - newFileCreationPage.setContainerFullPath(selectedResource.getFullPath()); - - // Make up a unique new name here. - // - String defaultModelBaseFilename = ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ServicebehaviorEditorFilenameDefaultBase"); - String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0); - String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; - for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) { - modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; - } - newFileCreationPage.setFileName(modelFilename); - } - } - } - initialObjectCreationPage = new ServicebehaviorModelWizardInitialObjectCreationPage("Whatever2"); - initialObjectCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ServicebehaviorModelWizard_label")); - initialObjectCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description")); - addPage(initialObjectCreationPage); - } - - /** - * Get the file from the page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IFile getModelFile() { - return newFileCreationPage.getModelFile(); - } - -} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemActionBarContributor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemActionBarContributor.java deleted file mode 100644 index c57651e0..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemActionBarContributor.java +++ /dev/null @@ -1,426 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.system.presentation; - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; - -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; - -import org.eclipse.emf.edit.ui.action.ControlAction; -import org.eclipse.emf.edit.ui.action.CreateChildAction; -import org.eclipse.emf.edit.ui.action.CreateSiblingAction; -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; -import org.eclipse.emf.edit.ui.action.LoadResourceAction; -import org.eclipse.emf.edit.ui.action.ValidateAction; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.action.SubContributionItem; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; - -/** - * This is the action bar contributor for the System model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class SystemActionBarContributor - extends EditingDomainActionBarContributor - implements ISelectionChangedListener { - /** - * This keeps track of the active editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IEditorPart activeEditorPart; - - /** - * This keeps track of the current selection provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelectionProvider selectionProvider; - - /** - * This action opens the Properties view. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IAction showPropertiesViewAction = - new Action(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { - @Override - public void run() { - try { - getPage().showView("org.eclipse.ui.views.PropertySheet"); - } - catch (PartInitException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - }; - - /** - * This action refreshes the viewer of the current editor if the editor - * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IAction refreshViewerAction = - new Action(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { - @Override - public boolean isEnabled() { - return activeEditorPart instanceof IViewerProvider; - } - - @Override - public void run() { - if (activeEditorPart instanceof IViewerProvider) { - Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); - if (viewer != null) { - viewer.refresh(); - } - } - } - }; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> createChildActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateChild actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IMenuManager createChildMenuManager; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> createSiblingActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateSibling actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IMenuManager createSiblingMenuManager; - - /** - * This creates an instance of the contributor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public SystemActionBarContributor() { - super(ADDITIONS_LAST_STYLE); - loadResourceAction = new LoadResourceAction(); - validateAction = new ValidateAction(); - controlAction = new ControlAction(); - } - - /** - * This adds Separators for editor additions to the tool bar. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void contributeToToolBar(IToolBarManager toolBarManager) { - toolBarManager.add(new Separator("system-settings")); - toolBarManager.add(new Separator("system-additions")); - } - - /** - * This adds to the menu bar a menu and some separators for editor additions, - * as well as the sub-menus for object creation items. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void contributeToMenu(IMenuManager menuManager) { - super.contributeToMenu(menuManager); - - IMenuManager submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_SystemEditor_menu"), "edu.kit.ipd.descartes.mm.systemMenuID"); - menuManager.insertAfter("additions", submenuManager); - submenuManager.add(new Separator("settings")); - submenuManager.add(new Separator("actions")); - submenuManager.add(new Separator("additions")); - submenuManager.add(new Separator("additions-end")); - - // Prepare for CreateChild item addition or removal. - // - createChildMenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); - submenuManager.insertBefore("additions", createChildMenuManager); - - // Prepare for CreateSibling item addition or removal. - // - createSiblingMenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); - submenuManager.insertBefore("additions", createSiblingMenuManager); - - // Force an update because Eclipse hides empty menus now. - // - submenuManager.addMenuListener - (new IMenuListener() { - public void menuAboutToShow(IMenuManager menuManager) { - menuManager.updateAll(true); - } - }); - - addGlobalActions(submenuManager); - } - - /** - * When the active editor changes, this remembers the change and registers with it as a selection provider. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setActiveEditor(IEditorPart part) { - super.setActiveEditor(part); - activeEditorPart = part; - - // Switch to the new selection provider. - // - if (selectionProvider != null) { - selectionProvider.removeSelectionChangedListener(this); - } - if (part == null) { - selectionProvider = null; - } - else { - selectionProvider = part.getSite().getSelectionProvider(); - selectionProvider.addSelectionChangedListener(this); - - // Fake a selection changed event to update the menus. - // - if (selectionProvider.getSelection() != null) { - selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection())); - } - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, - * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings - * that can be added to the selected object and updating the menus accordingly. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void selectionChanged(SelectionChangedEvent event) { - // Remove any menu items for old selection. - // - if (createChildMenuManager != null) { - depopulateManager(createChildMenuManager, createChildActions); - } - if (createSiblingMenuManager != null) { - depopulateManager(createSiblingMenuManager, createSiblingActions); - } - - // Query the new selection for appropriate new child/sibling descriptors - // - Collection<?> newChildDescriptors = null; - Collection<?> newSiblingDescriptors = null; - - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) { - Object object = ((IStructuredSelection)selection).getFirstElement(); - - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); - - newChildDescriptors = domain.getNewChildDescriptors(object, null); - newSiblingDescriptors = domain.getNewChildDescriptors(null, object); - } - - // Generate actions for selection; populate and redraw the menus. - // - createChildActions = generateCreateChildActions(newChildDescriptors, selection); - createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection); - - if (createChildMenuManager != null) { - populateManager(createChildMenuManager, createChildActions, null); - createChildMenuManager.update(true); - } - if (createSiblingMenuManager != null) { - populateManager(createSiblingMenuManager, createSiblingActions, null); - createSiblingMenuManager.update(true); - } - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, - * and returns the collection of these actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) { - Collection<IAction> actions = new ArrayList<IAction>(); - if (descriptors != null) { - for (Object descriptor : descriptors) { - actions.add(new CreateChildAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>, - * and returns the collection of these actions. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) { - Collection<IAction> actions = new ArrayList<IAction>(); - if (descriptors != null) { - for (Object descriptor : descriptors) { - actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, - * by inserting them before the specified contribution item <code>contributionID</code>. - * If <code>contributionID</code> is <code>null</code>, they are simply added. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { - if (actions != null) { - for (IAction action : actions) { - if (contributionID != null) { - manager.insertBefore(contributionID, action); - } - else { - manager.add(action); - } - } - } - } - - /** - * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) { - if (actions != null) { - IContributionItem[] items = manager.getItems(); - for (int i = 0; i < items.length; i++) { - // Look into SubContributionItems - // - IContributionItem contributionItem = items[i]; - while (contributionItem instanceof SubContributionItem) { - contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); - } - - // Delete the ActionContributionItems with matching action. - // - if (contributionItem instanceof ActionContributionItem) { - IAction action = ((ActionContributionItem)contributionItem).getAction(); - if (actions.contains(action)) { - manager.remove(contributionItem); - } - } - } - } - } - - /** - * This populates the pop-up menu before it appears. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void menuAboutToShow(IMenuManager menuManager) { - super.menuAboutToShow(menuManager); - MenuManager submenuManager = null; - - submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); - populateManager(submenuManager, createChildActions, null); - menuManager.insertBefore("edit", submenuManager); - - submenuManager = new MenuManager(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); - populateManager(submenuManager, createSiblingActions, null); - menuManager.insertBefore("edit", submenuManager); - } - - /** - * This inserts global actions before the "additions-end" separator. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void addGlobalActions(IMenuManager menuManager) { - menuManager.insertAfter("additions-end", new Separator("ui-actions")); - menuManager.insertAfter("ui-actions", showPropertiesViewAction); - - refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); - menuManager.insertAfter("ui-actions", refreshViewerAction); - - super.addGlobalActions(menuManager); - } - - /** - * This ensures that a delete action will clean up all references to deleted objects. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected boolean removeAllReferencesOnDelete() { - return true; - } - -} \ No newline at end of file diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemEditor.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemEditor.java deleted file mode 100644 index a9272ef6..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemEditor.java +++ /dev/null @@ -1,1839 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.system.presentation; - - -import java.io.IOException; -import java.io.InputStream; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EventObject; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; - -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; - -import org.eclipse.swt.SWT; - -import org.eclipse.swt.custom.CTabFolder; - -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.Transfer; - -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; - -import org.eclipse.swt.graphics.Point; - -import org.eclipse.swt.layout.FillLayout; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; - -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; - -import org.eclipse.ui.dialogs.SaveAsDialog; - -import org.eclipse.ui.ide.IGotoMarker; - -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.MultiPageEditorPart; - -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheet; -import org.eclipse.ui.views.properties.PropertySheetPage; - -import org.eclipse.emf.common.command.BasicCommandStack; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.common.command.CommandStackListener; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.common.ui.MarkerHelper; -import org.eclipse.emf.common.ui.ViewerPane; - -import org.eclipse.emf.common.ui.editor.ProblemEditorPart; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EValidator; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.emf.ecore.util.EcoreUtil; - -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; - -import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; - -import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; - -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; - -import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; - -import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; -import org.eclipse.emf.edit.ui.dnd.LocalTransfer; -import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; - -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider; - -import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper; -import org.eclipse.emf.edit.ui.util.EditUIUtil; - -import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; - -import edu.kit.ipd.descartes.mm.system.provider.SystemItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.identifier.provider.IdentifierItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import edu.kit.ipd.descartes.mm.core.provider.CoreItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.functions.provider.FunctionsItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.parameterdependencies.provider.ParameterdependenciesItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.repository.provider.RepositoryItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.resourceconfiguration.provider.ResourceconfigurationItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory; - -import edu.kit.ipd.descartes.mm.servicebehavior.provider.ServicebehaviorItemProviderAdapterFactory; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - - -/** - * This is an example of a System model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class SystemEditor - extends MultiPageEditorPart - implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker { - /** - * This keeps track of the editing domain that is used to track all changes to the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected AdapterFactoryEditingDomain editingDomain; - - /** - * This is the one adapter factory used for providing views of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ComposedAdapterFactory adapterFactory; - - /** - * This is the content outline page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IContentOutlinePage contentOutlinePage; - - /** - * This is a kludge... - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IStatusLineManager contentOutlineStatusLineManager; - - /** - * This is the content outline page's viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer contentOutlineViewer; - - /** - * This is the property sheet page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected PropertySheetPage propertySheetPage; - - /** - * This is the viewer that shadows the selection in the content outline. - * The parent relation must be correctly defined for this to work. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer selectionViewer; - - /** - * This inverts the roll of parent and child in the content provider and show parents as a tree. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer parentViewer; - - /** - * This shows how a tree view works. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer treeViewer; - - /** - * This shows how a list view works. - * A list viewer doesn't support icons. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ListViewer listViewer; - - /** - * This shows how a table view works. - * A table can be used as a list with icons. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TableViewer tableViewer; - - /** - * This shows how a tree view with columns works. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TreeViewer treeViewerWithColumns; - - /** - * This keeps track of the active viewer pane, in the book. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ViewerPane currentViewerPane; - - /** - * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Viewer currentViewer; - - /** - * This listens to which ever viewer is active. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelectionChangedListener selectionChangedListener; - - /** - * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); - - /** - * This keeps track of the selection of the editor as a whole. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ISelection editorSelection = StructuredSelection.EMPTY; - - /** - * The MarkerHelper is responsible for creating workspace resource markers presented - * in Eclipse's Problems View. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected MarkerHelper markerHelper = new EditUIMarkerHelper(); - - /** - * This listens for when the outline becomes active - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IPartListener partListener = - new IPartListener() { - public void partActivated(IWorkbenchPart p) { - if (p instanceof ContentOutline) { - if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) { - getActionBarContributor().setActiveEditor(SystemEditor.this); - - setCurrentViewer(contentOutlineViewer); - } - } - else if (p instanceof PropertySheet) { - if (((PropertySheet)p).getCurrentPage() == propertySheetPage) { - getActionBarContributor().setActiveEditor(SystemEditor.this); - handleActivate(); - } - } - else if (p == SystemEditor.this) { - handleActivate(); - } - } - public void partBroughtToTop(IWorkbenchPart p) { - // Ignore. - } - public void partClosed(IWorkbenchPart p) { - // Ignore. - } - public void partDeactivated(IWorkbenchPart p) { - // Ignore. - } - public void partOpened(IWorkbenchPart p) { - // Ignore. - } - }; - - /** - * Resources that have been removed since last activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> removedResources = new ArrayList<Resource>(); - - /** - * Resources that have been changed since last activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> changedResources = new ArrayList<Resource>(); - - /** - * Resources that have been saved. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<Resource> savedResources = new ArrayList<Resource>(); - - /** - * Map to store the diagnostic associated with a resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>(); - - /** - * Controls whether the problem indication should be updated. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean updateProblemIndication = true; - - /** - * Adapter used to update the problem indication when resources are demanded loaded. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EContentAdapter problemIndicationAdapter = - new EContentAdapter() { - @Override - public void notifyChanged(Notification notification) { - if (notification.getNotifier() instanceof Resource) { - switch (notification.getFeatureID(Resource.class)) { - case Resource.RESOURCE__IS_LOADED: - case Resource.RESOURCE__ERRORS: - case Resource.RESOURCE__WARNINGS: { - Resource resource = (Resource)notification.getNotifier(); - Diagnostic diagnostic = analyzeResourceProblems(resource, null); - if (diagnostic.getSeverity() != Diagnostic.OK) { - resourceToDiagnosticMap.put(resource, diagnostic); - } - else { - resourceToDiagnosticMap.remove(resource); - } - - if (updateProblemIndication) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - updateProblemIndication(); - } - }); - } - break; - } - } - } - else { - super.notifyChanged(notification); - } - } - - @Override - protected void setTarget(Resource target) { - basicSetTarget(target); - } - - @Override - protected void unsetTarget(Resource target) { - basicUnsetTarget(target); - } - }; - - /** - * This listens for workspace changes. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IResourceChangeListener resourceChangeListener = - new IResourceChangeListener() { - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - try { - class ResourceDeltaVisitor implements IResourceDeltaVisitor { - protected ResourceSet resourceSet = editingDomain.getResourceSet(); - protected Collection<Resource> changedResources = new ArrayList<Resource>(); - protected Collection<Resource> removedResources = new ArrayList<Resource>(); - - public boolean visit(IResourceDelta delta) { - if (delta.getResource().getType() == IResource.FILE) { - if (delta.getKind() == IResourceDelta.REMOVED || - delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) { - Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false); - if (resource != null) { - if (delta.getKind() == IResourceDelta.REMOVED) { - removedResources.add(resource); - } - else if (!savedResources.remove(resource)) { - changedResources.add(resource); - } - } - } - } - - return true; - } - - public Collection<Resource> getChangedResources() { - return changedResources; - } - - public Collection<Resource> getRemovedResources() { - return removedResources; - } - } - - final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - delta.accept(visitor); - - if (!visitor.getRemovedResources().isEmpty()) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - removedResources.addAll(visitor.getRemovedResources()); - if (!isDirty()) { - getSite().getPage().closeEditor(SystemEditor.this, false); - } - } - }); - } - - if (!visitor.getChangedResources().isEmpty()) { - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - changedResources.addAll(visitor.getChangedResources()); - if (getSite().getPage().getActiveEditor() == SystemEditor.this) { - handleActivate(); - } - } - }); - } - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - }; - - /** - * Handles activation of the editor or it's associated views. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void handleActivate() { - // Recompute the read only state. - // - if (editingDomain.getResourceToReadOnlyMap() != null) { - editingDomain.getResourceToReadOnlyMap().clear(); - - // Refresh any actions that may become enabled or disabled. - // - setSelection(getSelection()); - } - - if (!removedResources.isEmpty()) { - if (handleDirtyConflict()) { - getSite().getPage().closeEditor(SystemEditor.this, false); - } - else { - removedResources.clear(); - changedResources.clear(); - savedResources.clear(); - } - } - else if (!changedResources.isEmpty()) { - changedResources.removeAll(savedResources); - handleChangedResources(); - changedResources.clear(); - savedResources.clear(); - } - } - - /** - * Handles what to do with changed resources on activation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void handleChangedResources() { - if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) { - if (isDirty()) { - changedResources.addAll(editingDomain.getResourceSet().getResources()); - } - editingDomain.getCommandStack().flush(); - - updateProblemIndication = false; - for (Resource resource : changedResources) { - if (resource.isLoaded()) { - resource.unload(); - try { - resource.load(Collections.EMPTY_MAP); - } - catch (IOException exception) { - if (!resourceToDiagnosticMap.containsKey(resource)) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - } - } - } - - if (AdapterFactoryEditingDomain.isStale(editorSelection)) { - setSelection(StructuredSelection.EMPTY); - } - - updateProblemIndication = true; - updateProblemIndication(); - } - } - - /** - * Updates the problems indication with the information described in the specified diagnostic. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void updateProblemIndication() { - if (updateProblemIndication) { - BasicDiagnostic diagnostic = - new BasicDiagnostic - (Diagnostic.OK, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - null, - new Object [] { editingDomain.getResourceSet() }); - for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) { - if (childDiagnostic.getSeverity() != Diagnostic.OK) { - diagnostic.add(childDiagnostic); - } - } - - int lastEditorPage = getPageCount() - 1; - if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) { - ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic); - if (diagnostic.getSeverity() != Diagnostic.OK) { - setActivePage(lastEditorPage); - } - } - else if (diagnostic.getSeverity() != Diagnostic.OK) { - ProblemEditorPart problemEditorPart = new ProblemEditorPart(); - problemEditorPart.setDiagnostic(diagnostic); - problemEditorPart.setMarkerHelper(markerHelper); - try { - addPage(++lastEditorPage, problemEditorPart, getEditorInput()); - setPageText(lastEditorPage, problemEditorPart.getPartName()); - setActivePage(lastEditorPage); - showTabs(); - } - catch (PartInitException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - - if (markerHelper.hasMarkers(editingDomain.getResourceSet())) { - markerHelper.deleteMarkers(editingDomain.getResourceSet()); - if (diagnostic.getSeverity() != Diagnostic.OK) { - try { - markerHelper.createMarkers(diagnostic); - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - } - } - } - - /** - * Shows a dialog that asks if conflicting changes should be discarded. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean handleDirtyConflict() { - return - MessageDialog.openQuestion - (getSite().getShell(), - getString("_UI_FileConflict_label"), - getString("_WARN_FileConflict")); - } - - /** - * This creates a model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public SystemEditor() { - super(); - initializeEditingDomain(); - } - - /** - * This sets up the editing domain for the model editor. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void initializeEditingDomain() { - // Create an adapter factory that yields item providers. - // - adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - - adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new RepositoryItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ServicebehaviorItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new SystemItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ParameterdependenciesItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new FunctionsItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new CoreItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new IdentifierItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ResourceconfigurationItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ResourcetypeItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); - - // Create the command stack that will notify this editor as commands are executed. - // - BasicCommandStack commandStack = new BasicCommandStack(); - - // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. - // - commandStack.addCommandStackListener - (new CommandStackListener() { - public void commandStackChanged(final EventObject event) { - getContainer().getDisplay().asyncExec - (new Runnable() { - public void run() { - firePropertyChange(IEditorPart.PROP_DIRTY); - - // Try to select the affected objects. - // - Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); - if (mostRecentCommand != null) { - setSelectionToViewer(mostRecentCommand.getAffectedObjects()); - } - if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) { - propertySheetPage.refresh(); - } - } - }); - } - }); - - // Create the editing domain with a special command stack. - // - editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>()); - } - - /** - * This is here for the listener to be able to call it. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void firePropertyChange(int action) { - super.firePropertyChange(action); - } - - /** - * This sets the selection into whichever viewer is active. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSelectionToViewer(Collection<?> collection) { - final Collection<?> theSelection = collection; - // Make sure it's okay. - // - if (theSelection != null && !theSelection.isEmpty()) { - Runnable runnable = - new Runnable() { - public void run() { - // Try to select the items in the current content viewer of the editor. - // - if (currentViewer != null) { - currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); - } - } - }; - getSite().getShell().getDisplay().asyncExec(runnable); - } - } - - /** - * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. - * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} - * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EditingDomain getEditingDomain() { - return editingDomain; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object [] getElements(Object object) { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object [] getChildren(Object object) { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean hasChildren(Object object) { - Object parent = super.getParent(object); - return parent != null; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object getParent(Object object) { - return null; - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCurrentViewerPane(ViewerPane viewerPane) { - if (currentViewerPane != viewerPane) { - if (currentViewerPane != null) { - currentViewerPane.showFocus(false); - } - currentViewerPane = viewerPane; - } - setCurrentViewer(currentViewerPane.getViewer()); - } - - /** - * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, - * is the current one. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setCurrentViewer(Viewer viewer) { - // If it is changing... - // - if (currentViewer != viewer) { - if (selectionChangedListener == null) { - // Create the listener on demand. - // - selectionChangedListener = - new ISelectionChangedListener() { - // This just notifies those things that are affected by the section. - // - public void selectionChanged(SelectionChangedEvent selectionChangedEvent) { - setSelection(selectionChangedEvent.getSelection()); - } - }; - } - - // Stop listening to the old one. - // - if (currentViewer != null) { - currentViewer.removeSelectionChangedListener(selectionChangedListener); - } - - // Start listening to the new one. - // - if (viewer != null) { - viewer.addSelectionChangedListener(selectionChangedListener); - } - - // Remember it. - // - currentViewer = viewer; - - // Set the editors selection based on the current viewer's selection. - // - setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); - } - } - - /** - * This returns the viewer as required by the {@link IViewerProvider} interface. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Viewer getViewer() { - return currentViewer; - } - - /** - * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createContextMenuFor(StructuredViewer viewer) { - MenuManager contextMenu = new MenuManager("#PopUp"); - contextMenu.add(new Separator("additions")); - contextMenu.setRemoveAllWhenShown(true); - contextMenu.addMenuListener(this); - Menu menu= contextMenu.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); - - int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; - Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() }; - viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); - viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); - } - - /** - * This is the method called to load a resource into the editing domain's resource set based on the editor's input. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createModel() { - URI resourceURI = EditUIUtil.getURI(getEditorInput()); - Exception exception = null; - Resource resource = null; - try { - // Load the resource through the editing domain. - // - resource = editingDomain.getResourceSet().getResource(resourceURI, true); - } - catch (Exception e) { - exception = e; - resource = editingDomain.getResourceSet().getResource(resourceURI, false); - } - - Diagnostic diagnostic = analyzeResourceProblems(resource, exception); - if (diagnostic.getSeverity() != Diagnostic.OK) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); - } - - /** - * Returns a diagnostic describing the errors and warnings listed in the resource - * and the specified exception (if any). - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) { - if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) { - BasicDiagnostic basicDiagnostic = - new BasicDiagnostic - (Diagnostic.ERROR, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object [] { exception == null ? (Object)resource : exception }); - basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); - return basicDiagnostic; - } - else if (exception != null) { - return - new BasicDiagnostic - (Diagnostic.ERROR, - "edu.kit.ipd.descartes.mm.applicationlevel.editor", - 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object[] { exception }); - } - else { - return Diagnostic.OK_INSTANCE; - } - } - - /** - * This is the method used by the framework to install your own controls. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void createPages() { - // Creates the model from the editor input - // - createModel(); - - // Only creates the other pages if there is something that can be edited - // - if (!getEditingDomain().getResourceSet().getResources().isEmpty()) { - // Create a page for the selection tree view. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), SystemEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - Tree tree = new Tree(composite, SWT.MULTI); - TreeViewer newTreeViewer = new TreeViewer(tree); - return newTreeViewer; - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - selectionViewer = (TreeViewer)viewerPane.getViewer(); - selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - - selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - selectionViewer.setInput(editingDomain.getResourceSet()); - selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - viewerPane.setTitle(editingDomain.getResourceSet()); - - new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); - - createContextMenuFor(selectionViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_SelectionPage_label")); - } - - // Create a page for the parent tree view. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), SystemEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - Tree tree = new Tree(composite, SWT.MULTI); - TreeViewer newTreeViewer = new TreeViewer(tree); - return newTreeViewer; - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - parentViewer = (TreeViewer)viewerPane.getViewer(); - parentViewer.setAutoExpandLevel(30); - parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory)); - parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(parentViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_ParentPage_label")); - } - - // This is the page for the list viewer - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), SystemEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new ListViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - listViewer = (ListViewer)viewerPane.getViewer(); - listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(listViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_ListPage_label")); - } - - // This is the page for the tree viewer - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), SystemEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TreeViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - treeViewer = (TreeViewer)viewerPane.getViewer(); - treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); - - createContextMenuFor(treeViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TreePage_label")); - } - - // This is the page for the table viewer. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), SystemEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TableViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - tableViewer = (TableViewer)viewerPane.getViewer(); - - Table table = tableViewer.getTable(); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - TableColumn objectColumn = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(3, 100, true)); - objectColumn.setText(getString("_UI_ObjectColumn_label")); - objectColumn.setResizable(true); - - TableColumn selfColumn = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(2, 100, true)); - selfColumn.setText(getString("_UI_SelfColumn_label")); - selfColumn.setResizable(true); - - tableViewer.setColumnProperties(new String [] {"a", "b"}); - tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(tableViewer); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TablePage_label")); - } - - // This is the page for the table tree viewer. - // - { - ViewerPane viewerPane = - new ViewerPane(getSite().getPage(), SystemEditor.this) { - @Override - public Viewer createViewer(Composite composite) { - return new TreeViewer(composite); - } - @Override - public void requestActivation() { - super.requestActivation(); - setCurrentViewerPane(this); - } - }; - viewerPane.createControl(getContainer()); - - treeViewerWithColumns = (TreeViewer)viewerPane.getViewer(); - - Tree tree = treeViewerWithColumns.getTree(); - tree.setLayoutData(new FillLayout()); - tree.setHeaderVisible(true); - tree.setLinesVisible(true); - - TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE); - objectColumn.setText(getString("_UI_ObjectColumn_label")); - objectColumn.setResizable(true); - objectColumn.setWidth(250); - - TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE); - selfColumn.setText(getString("_UI_SelfColumn_label")); - selfColumn.setResizable(true); - selfColumn.setWidth(200); - - treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"}); - treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - - createContextMenuFor(treeViewerWithColumns); - int pageIndex = addPage(viewerPane.getControl()); - setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); - } - - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - setActivePage(0); - } - }); - } - - // Ensures that this editor will only display the page's tab - // area if there are more than one page - // - getContainer().addControlListener - (new ControlAdapter() { - boolean guard = false; - @Override - public void controlResized(ControlEvent event) { - if (!guard) { - guard = true; - hideTabs(); - guard = false; - } - } - }); - - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - updateProblemIndication(); - } - }); - } - - /** - * If there is just one page in the multi-page editor part, - * this hides the single tab at the bottom. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void hideTabs() { - if (getPageCount() <= 1) { - setPageText(0, ""); - if (getContainer() instanceof CTabFolder) { - ((CTabFolder)getContainer()).setTabHeight(1); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y + 6); - } - } - } - - /** - * If there is more than one page in the multi-page editor part, - * this shows the tabs at the bottom. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void showTabs() { - if (getPageCount() > 1) { - setPageText(0, getString("_UI_SelectionPage_label")); - if (getContainer() instanceof CTabFolder) { - ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y - 6); - } - } - } - - /** - * This is used to track the active viewer. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected void pageChange(int pageIndex) { - super.pageChange(pageIndex); - - if (contentOutlinePage != null) { - handleContentOutlineSelection(contentOutlinePage.getSelection()); - } - } - - /** - * This is how the framework determines which interfaces we implement. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class key) { - if (key.equals(IContentOutlinePage.class)) { - return showOutlineView() ? getContentOutlinePage() : null; - } - else if (key.equals(IPropertySheetPage.class)) { - return getPropertySheetPage(); - } - else if (key.equals(IGotoMarker.class)) { - return this; - } - else { - return super.getAdapter(key); - } - } - - /** - * This accesses a cached version of the content outliner. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IContentOutlinePage getContentOutlinePage() { - if (contentOutlinePage == null) { - // The content outline is just a tree. - // - class MyContentOutlinePage extends ContentOutlinePage { - @Override - public void createControl(Composite parent) { - super.createControl(parent); - contentOutlineViewer = getTreeViewer(); - contentOutlineViewer.addSelectionChangedListener(this); - - // Set up the tree viewer. - // - contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - contentOutlineViewer.setInput(editingDomain.getResourceSet()); - - // Make sure our popups work. - // - createContextMenuFor(contentOutlineViewer); - - if (!editingDomain.getResourceSet().getResources().isEmpty()) { - // Select the root object in the view. - // - contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - } - } - - @Override - public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { - super.makeContributions(menuManager, toolBarManager, statusLineManager); - contentOutlineStatusLineManager = statusLineManager; - } - - @Override - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - } - - contentOutlinePage = new MyContentOutlinePage(); - - // Listen to selection so that we can handle it is a special way. - // - contentOutlinePage.addSelectionChangedListener - (new ISelectionChangedListener() { - // This ensures that we handle selections correctly. - // - public void selectionChanged(SelectionChangedEvent event) { - handleContentOutlineSelection(event.getSelection()); - } - }); - } - - return contentOutlinePage; - } - - /** - * This accesses a cached version of the property sheet. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IPropertySheetPage getPropertySheetPage() { - if (propertySheetPage == null) { - propertySheetPage = - new ExtendedPropertySheetPage(editingDomain) { - @Override - public void setSelectionToViewer(List<?> selection) { - SystemEditor.this.setSelectionToViewer(selection); - SystemEditor.this.setFocus(); - } - - @Override - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - }; - propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); - } - - return propertySheetPage; - } - - /** - * This deals with how we want selection in the outliner to affect the other views. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void handleContentOutlineSelection(ISelection selection) { - if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { - Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator(); - if (selectedElements.hasNext()) { - // Get the first selected element. - // - Object selectedElement = selectedElements.next(); - - // If it's the selection viewer, then we want it to select the same selection as this selection. - // - if (currentViewerPane.getViewer() == selectionViewer) { - ArrayList<Object> selectionList = new ArrayList<Object>(); - selectionList.add(selectedElement); - while (selectedElements.hasNext()) { - selectionList.add(selectedElements.next()); - } - - // Set the selection to the widget. - // - selectionViewer.setSelection(new StructuredSelection(selectionList)); - } - else { - // Set the input to the widget. - // - if (currentViewerPane.getViewer().getInput() != selectedElement) { - currentViewerPane.getViewer().setInput(selectedElement); - currentViewerPane.setTitle(selectedElement); - } - } - } - } - } - - /** - * This is for implementing {@link IEditorPart} and simply tests the command stack. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean isDirty() { - return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded(); - } - - /** - * This is for implementing {@link IEditorPart} and simply saves the model file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void doSave(IProgressMonitor progressMonitor) { - // Save only resources that have actually changed. - // - final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); - saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); - - // Do the work within an operation because this is a long running activity that modifies the workbench. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - // This is the method that gets invoked when the operation runs. - // - @Override - public void execute(IProgressMonitor monitor) { - // Save the resources to the file system. - // - boolean first = true; - for (Resource resource : editingDomain.getResourceSet().getResources()) { - if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { - try { - long timeStamp = resource.getTimeStamp(); - resource.save(saveOptions); - if (resource.getTimeStamp() != timeStamp) { - savedResources.add(resource); - } - } - catch (Exception exception) { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - first = false; - } - } - } - }; - - updateProblemIndication = false; - try { - // This runs the options, and shows progress. - // - new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); - - // Refresh the necessary state. - // - ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); - firePropertyChange(IEditorPart.PROP_DIRTY); - } - catch (Exception exception) { - // Something went wrong that shouldn't. - // - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - updateProblemIndication = true; - updateProblemIndication(); - } - - /** - * This returns whether something has been persisted to the URI of the specified resource. - * The implementation uses the URI converter from the editor's resource set to try to open an input stream. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean isPersisted(Resource resource) { - boolean result = false; - try { - InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); - if (stream != null) { - result = true; - stream.close(); - } - } - catch (IOException e) { - // Ignore - } - return result; - } - - /** - * This always returns true because it is not currently supported. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean isSaveAsAllowed() { - return true; - } - - /** - * This also changes the editor's input. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void doSaveAs() { - SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); - saveAsDialog.open(); - IPath path = saveAsDialog.getResult(); - if (path != null) { - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - if (file != null) { - doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void doSaveAs(URI uri, IEditorInput editorInput) { - (editingDomain.getResourceSet().getResources().get(0)).setURI(uri); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - IProgressMonitor progressMonitor = - getActionBars().getStatusLineManager() != null ? - getActionBars().getStatusLineManager().getProgressMonitor() : - new NullProgressMonitor(); - doSave(progressMonitor); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void gotoMarker(IMarker marker) { - try { - if (marker.getType().equals(EValidator.MARKER)) { - String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null); - if (uriAttribute != null) { - URI uri = URI.createURI(uriAttribute); - EObject eObject = editingDomain.getResourceSet().getEObject(uri, true); - if (eObject != null) { - setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject))); - } - } - } - } - catch (CoreException exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - } - - /** - * This is called during startup. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void init(IEditorSite site, IEditorInput editorInput) { - setSite(site); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - site.setSelectionProvider(this); - site.getPage().addPartListener(partListener); - ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setFocus() { - if (currentViewerPane != null) { - currentViewerPane.setFocus(); - } - else { - getControl(getActivePage()).setFocus(); - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ISelection getSelection() { - return editorSelection; - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. - * Calling this result will notify the listeners. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSelection(ISelection selection) { - editorSelection = selection; - - for (ISelectionChangedListener listener : selectionChangedListeners) { - listener.selectionChanged(new SelectionChangedEvent(this, selection)); - } - setStatusLineManager(selection); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setStatusLineManager(ISelection selection) { - IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? - contentOutlineStatusLineManager : getActionBars().getStatusLineManager(); - - if (statusLineManager != null) { - if (selection instanceof IStructuredSelection) { - Collection<?> collection = ((IStructuredSelection)selection).toList(); - switch (collection.size()) { - case 0: { - statusLineManager.setMessage(getString("_UI_NoObjectSelected")); - break; - } - case 1: { - String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next()); - statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); - break; - } - default: { - statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size()))); - break; - } - } - } - else { - statusLineManager.setMessage(""); - } - } - } - - /** - * This looks up a string in the plugin's plugin.properties file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static String getString(String key) { - return ApplicationlevelEditorPlugin.INSTANCE.getString(key); - } - - /** - * This looks up a string in plugin.properties, making a substitution. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static String getString(String key, Object s1) { - return ApplicationlevelEditorPlugin.INSTANCE.getString(key, new Object [] { s1 }); - } - - /** - * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void menuAboutToShow(IMenuManager menuManager) { - ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EditingDomainActionBarContributor getActionBarContributor() { - return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IActionBars getActionBars() { - return getActionBarContributor().getActionBars(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public AdapterFactory getAdapterFactory() { - return adapterFactory; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void dispose() { - updateProblemIndication = false; - - ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); - - getSite().getPage().removePartListener(partListener); - - adapterFactory.dispose(); - - if (getActionBarContributor().getActiveEditor() == this) { - getActionBarContributor().setActiveEditor(null); - } - - if (propertySheetPage != null) { - propertySheetPage.dispose(); - } - - if (contentOutlinePage != null) { - contentOutlinePage.dispose(); - } - - super.dispose(); - } - - /** - * Returns whether the outline view should be presented to the user. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean showOutlineView() { - return true; - } -} diff --git a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemModelWizard.java b/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemModelWizard.java deleted file mode 100644 index ddd28fd3..00000000 --- a/edu.kit.ipd.descartes.mm.applicationlevel.editor/src/edu/kit/ipd/descartes/mm/system/presentation/SystemModelWizard.java +++ /dev/null @@ -1,630 +0,0 @@ -/** - * Copyright 2009-2012, Descartes Research Group, SDQ, IPD, KIT - */ -package edu.kit.ipd.descartes.mm.system.presentation; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.StringTokenizer; - -import org.eclipse.emf.common.CommonPlugin; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.jface.dialogs.MessageDialog; - -import org.eclipse.jface.viewers.IStructuredSelection; - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; - -import org.eclipse.swt.SWT; - -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.ModifyEvent; - -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; - -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; - -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; - -import edu.kit.ipd.descartes.mm.system.SystemFactory; -import edu.kit.ipd.descartes.mm.system.SystemPackage; -import edu.kit.ipd.descartes.mm.applicationlevel.provider.ApplicationlevelEditPlugin; - - -import edu.kit.ipd.descartes.mm.applicationlevel.presentation.ApplicationlevelEditorPlugin; - -import org.eclipse.core.runtime.Path; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; - -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; - - -/** - * This is a simple wizard for creating a new model file. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class SystemModelWizard extends Wizard implements INewWizard { - /** - * The supported extensions for created files. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final List<String> FILE_EXTENSIONS = - Collections.unmodifiableList(Arrays.asList(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_SystemEditorFilenameExtensions").split("\\s*,\\s*"))); - - /** - * A formatted list of supported file extensions, suitable for display. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String FORMATTED_FILE_EXTENSIONS = - ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_SystemEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); - - /** - * This caches an instance of the model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected SystemPackage systemPackage = SystemPackage.eINSTANCE; - - /** - * This caches an instance of the model factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected SystemFactory systemFactory = systemPackage.getSystemFactory(); - - /** - * This is the file creation page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected SystemModelWizardNewFileCreationPage newFileCreationPage; - - /** - * This is the initial object creation page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected SystemModelWizardInitialObjectCreationPage initialObjectCreationPage; - - /** - * Remember the selection during initialization for populating the default container. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IStructuredSelection selection; - - /** - * Remember the workbench during initialization. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IWorkbench workbench; - - /** - * Caches the names of the types that can be created as the root object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected List<String> initialObjectNames; - - /** - * This just records the information. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.workbench = workbench; - this.selection = selection; - setWindowTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_label")); - setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(ApplicationlevelEditorPlugin.INSTANCE.getImage("full/wizban/NewSystem"))); - } - - /** - * Returns the names of the types that can be created as the root object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<String> getInitialObjectNames() { - if (initialObjectNames == null) { - initialObjectNames = new ArrayList<String>(); - for (EClassifier eClassifier : systemPackage.getEClassifiers()) { - if (eClassifier instanceof EClass) { - EClass eClass = (EClass)eClassifier; - if (!eClass.isAbstract()) { - initialObjectNames.add(eClass.getName()); - } - } - } - Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator()); - } - return initialObjectNames; - } - - /** - * Create a new model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EObject createInitialModel() { - EClass eClass = (EClass)systemPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName()); - EObject rootObject = systemFactory.create(eClass); - return rootObject; - } - - /** - * Do the work after everything is specified. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean performFinish() { - try { - // Remember the file. - // - final IFile modelFile = getModelFile(); - - // Do the work within an operation. - // - WorkspaceModifyOperation operation = - new WorkspaceModifyOperation() { - @Override - protected void execute(IProgressMonitor progressMonitor) { - try { - // Create a resource set - // - ResourceSet resourceSet = new ResourceSetImpl(); - - // Get the URI of the model file. - // - URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true); - - // Create a resource for this file. - // - Resource resource = resourceSet.createResource(fileURI); - - // Add the initial model object to the contents. - // - EObject rootObject = createInitialModel(); - if (rootObject != null) { - resource.getContents().add(rootObject); - } - - // Save the contents of the resource to the file system. - // - Map<Object, Object> options = new HashMap<Object, Object>(); - options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding()); - resource.save(options); - } - catch (Exception exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - } - finally { - progressMonitor.done(); - } - } - }; - - getContainer().run(false, false, operation); - - // Select the new file resource in the current view. - // - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IWorkbenchPage page = workbenchWindow.getActivePage(); - final IWorkbenchPart activePart = page.getActivePart(); - if (activePart instanceof ISetSelectionTarget) { - final ISelection targetSelection = new StructuredSelection(modelFile); - getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - ((ISetSelectionTarget)activePart).selectReveal(targetSelection); - } - }); - } - - // Open an editor on the new file. - // - try { - page.openEditor - (new FileEditorInput(modelFile), - workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId()); - } - catch (PartInitException exception) { - MessageDialog.openError(workbenchWindow.getShell(), ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); - return false; - } - - return true; - } - catch (Exception exception) { - ApplicationlevelEditorPlugin.INSTANCE.log(exception); - return false; - } - } - - /** - * This is the one page of the wizard. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class SystemModelWizardNewFileCreationPage extends WizardNewFileCreationPage { - /** - * Pass in the selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public SystemModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) { - super(pageId, selection); - } - - /** - * The framework calls this to see if the file is correct. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected boolean validatePage() { - if (super.validatePage()) { - String extension = new Path(getFileName()).getFileExtension(); - if (extension == null || !FILE_EXTENSIONS.contains(extension)) { - String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; - setErrorMessage(ApplicationlevelEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS })); - return false; - } - return true; - } - return false; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IFile getModelFile() { - return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName())); - } - } - - /** - * This is the page where the type of object to create is selected. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public class SystemModelWizardInitialObjectCreationPage extends WizardPage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Combo initialObjectField; - - /** - * @generated - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - */ - protected List<String> encodings; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Combo encodingField; - - /** - * Pass in the selection. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public SystemModelWizardInitialObjectCreationPage(String pageId) { - super(pageId); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); { - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.verticalSpacing = 12; - composite.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData(data); - } - - Label containerLabel = new Label(composite, SWT.LEFT); - { - containerLabel.setText(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_ModelObject")); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - containerLabel.setLayoutData(data); - } - - initialObjectField = new Combo(composite, SWT.BORDER); - { - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - initialObjectField.setLayoutData(data); - } - - for (String objectName : getInitialObjectNames()) { - initialObjectField.add(getLabel(objectName)); - } - - if (initialObjectField.getItemCount() == 1) { - initialObjectField.select(0); - } - initialObjectField.addModifyListener(validator); - - Label encodingLabel = new Label(composite, SWT.LEFT); - { - encodingLabel.setText(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_XMLEncoding")); - - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - encodingLabel.setLayoutData(data); - } - encodingField = new Combo(composite, SWT.BORDER); - { - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - encodingField.setLayoutData(data); - } - - for (String encoding : getEncodings()) { - encodingField.add(encoding); - } - - encodingField.select(0); - encodingField.addModifyListener(validator); - - setPageComplete(validatePage()); - setControl(composite); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ModifyListener validator = - new ModifyListener() { - public void modifyText(ModifyEvent e) { - setPageComplete(validatePage()); - } - }; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected boolean validatePage() { - return getInitialObjectName() != null && getEncodings().contains(encodingField.getText()); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - if (initialObjectField.getItemCount() == 1) { - initialObjectField.clearSelection(); - encodingField.setFocus(); - } - else { - encodingField.clearSelection(); - initialObjectField.setFocus(); - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getInitialObjectName() { - String label = initialObjectField.getText(); - - for (String name : getInitialObjectNames()) { - if (getLabel(name).equals(label)) { - return name; - } - } - return null; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getEncoding() { - return encodingField.getText(); - } - - /** - * Returns the label for the specified type name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected String getLabel(String typeName) { - try { - return ApplicationlevelEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); - } - catch(MissingResourceException mre) { - ApplicationlevelEditorPlugin.INSTANCE.log(mre); - } - return typeName; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Collection<String> getEncodings() { - if (encodings == null) { - encodings = new ArrayList<String>(); - for (StringTokenizer stringTokenizer = new StringTokenizer(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) { - encodings.add(stringTokenizer.nextToken()); - } - } - return encodings; - } - } - - /** - * The framework calls this to create the contents of the wizard. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void addPages() { - // Create a page, set the title, and the initial model file name. - // - newFileCreationPage = new SystemModelWizardNewFileCreationPage("Whatever", selection); - newFileCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_SystemModelWizard_label")); - newFileCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_SystemModelWizard_description")); - newFileCreationPage.setFileName(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_SystemEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); - addPage(newFileCreationPage); - - // Try and get the resource selection to determine a current directory for the file dialog. - // - if (selection != null && !selection.isEmpty()) { - // Get the resource... - // - Object selectedElement = selection.iterator().next(); - if (selectedElement instanceof IResource) { - // Get the resource parent, if its a file. - // - IResource selectedResource = (IResource)selectedElement; - if (selectedResource.getType() == IResource.FILE) { - selectedResource = selectedResource.getParent(); - } - - // This gives us a directory... - // - if (selectedResource instanceof IFolder || selectedResource instanceof IProject) { - // Set this for the container. - // - newFileCreationPage.setContainerFullPath(selectedResource.getFullPath()); - - // Make up a unique new name here. - // - String defaultModelBaseFilename = ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_SystemEditorFilenameDefaultBase"); - String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0); - String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; - for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) { - modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; - } - newFileCreationPage.setFileName(modelFilename); - } - } - } - initialObjectCreationPage = new SystemModelWizardInitialObjectCreationPage("Whatever2"); - initialObjectCreationPage.setTitle(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_SystemModelWizard_label")); - initialObjectCreationPage.setDescription(ApplicationlevelEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description")); - addPage(initialObjectCreationPage); - } - - /** - * Get the file from the page. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IFile getModelFile() { - return newFileCreationPage.getModelFile(); - } - -} -- GitLab