From dfaa0dad0203e4a2cc4e08b91445cd7fa5264741 Mon Sep 17 00:00:00 2001 From: Chris Wiebe Date: Wed, 22 Sep 2004 18:27:55 +0000 Subject: [PATCH] 2004-09-22 Chris Wiebe new file wizards * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCreationWizardPage.java * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties * src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java * src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java * src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/BaseClassSelectionDialog.java * src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java * src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java * src/org/eclipse/cdt/internal/ui/CPluginImages.java * icons/full/ctool16/newcfile_wiz.gif * icons/full/ctool16/newhfile_wiz.gif * icons/full/dtool16/newcfile_wiz.gif * icons/full/dtool16/newhfile_wiz.gif * icons/full/etool16/newcfile_wiz.gif * icons/full/etool16/newhfile_wiz.gif * icons/full/wizban/newcfile_wiz.gif * icons/full/wizban/newhfile_wiz.gif * src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java * src/org/eclipse/cdt/ui/wizards/NewClassWizard.java * src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java * src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java * src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java * src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java * plugin.properties * plugin.xml --- core/org.eclipse.cdt.ui/ChangeLog | 39 ++ .../icons/full/ctool16/newcfile_wiz.gif | Bin 0 -> 376 bytes .../icons/full/ctool16/newhfile_wiz.gif | Bin 0 -> 379 bytes .../icons/full/dtool16/newcfile_wiz.gif | Bin 0 -> 240 bytes .../icons/full/dtool16/newhfile_wiz.gif | Bin 0 -> 244 bytes .../icons/full/etool16/newcfile_wiz.gif | Bin 0 -> 376 bytes .../icons/full/etool16/newhfile_wiz.gif | Bin 0 -> 379 bytes .../icons/full/wizban/newcfile_wiz.gif | Bin 0 -> 2811 bytes .../icons/full/wizban/newhfile_wiz.gif | Bin 0 -> 2825 bytes core/org.eclipse.cdt.ui/plugin.properties | 42 +- core/org.eclipse.cdt.ui/plugin.xml | 114 +++- .../cdt/internal/ui/CPluginImages.java | 3 + .../ui/wizards/AbstractOpenWizardAction.java | 21 +- .../wizards/AbstractWizardDropDownAction.java | 116 ++-- .../ui/wizards/BaseClassSelectionDialog.java | 2 + .../internal/ui/wizards/CWizardRegistry.java | 350 +++++++++++ .../ui/wizards/NewFileDropDownAction.java | 23 + .../ui/wizards/NewProjectDropDownAction.java | 85 +-- .../ui/wizards/NewTypeDropDownAction.java | 55 +- .../ui/wizards/OpenNewFileWizardAction.java | 4 + .../classwizard/NewClassCodeGenerator.java | 3 +- .../NewClassCreationWizardPage.java | 63 +- .../NewClassWizardMessages.properties | 9 - .../SourceFileSelectionDialog.java | 2 +- .../AbstractFileCreationWizard.java | 73 +++ .../AbstractFileCreationWizardPage.java | 583 ++++++++++++++++++ .../filewizard/NewFileWizardMessages.java | 60 ++ .../NewFileWizardMessages.properties | 68 ++ .../NewHeaderFileCreationWizardPage.java | 168 +++++ .../NewSourceFileCreationWizardPage.java | 167 +++++ .../NewSourceFileGenerator.java | 6 +- .../cdt/ui/wizards/NewClassWizard.java | 1 + .../cdt/ui/wizards/NewClassWizardPage.java | 11 +- .../cdt/ui/wizards/NewFileCreationWizard.java | 16 + .../wizards/NewHeaderFileCreationWizard.java | 37 ++ .../wizards/NewSourceFileCreationWizard.java | 37 ++ 36 files changed, 1845 insertions(+), 313 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/icons/full/ctool16/newcfile_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/ctool16/newhfile_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/dtool16/newcfile_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/dtool16/newhfile_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/etool16/newcfile_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/etool16/newhfile_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/wizban/newcfile_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/wizban/newhfile_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java rename core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/{classwizard => filewizard}/NewSourceFileGenerator.java (95%) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index d99a21ade5f..a0aff9d71be 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,42 @@ +2004-09-22 Chris Wiebe + + new file wizards + * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java + * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCreationWizardPage.java + * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties + * src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java + * src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java + * src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java + * src/org/eclipse/cdt/internal/ui/wizards/BaseClassSelectionDialog.java + * src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java + * src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java + * src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java + * src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java + * src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java + * src/org/eclipse/cdt/internal/ui/CPluginImages.java + * icons/full/ctool16/newcfile_wiz.gif + * icons/full/ctool16/newhfile_wiz.gif + * icons/full/dtool16/newcfile_wiz.gif + * icons/full/dtool16/newhfile_wiz.gif + * icons/full/etool16/newcfile_wiz.gif + * icons/full/etool16/newhfile_wiz.gif + * icons/full/wizban/newcfile_wiz.gif + * icons/full/wizban/newhfile_wiz.gif + * src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java + * src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java + * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java + * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties + * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java + * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java + * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java + * src/org/eclipse/cdt/ui/wizards/NewClassWizard.java + * src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java + * src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java + * src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java + * src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java + * plugin.properties + * plugin.xml + 2004-09-21 Alain Magloire Duplication in the CView ILibraryReferece. * src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java diff --git a/core/org.eclipse.cdt.ui/icons/full/ctool16/newcfile_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/ctool16/newcfile_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..138f6750258a7c87cf447f26d08f9e453bfa5add GIT binary patch literal 376 zcmZ?wbhEHb6krfwxXQp_Z@)i2et&)a{!d?jfBW(0*YCeSfBm`l;>VLWKcBz*`S#PV zJI}x0fBEC#s~@jE{QU9j@3VJ5KYaadU%!9ZsSn?O{r&pm_xGQ_fB*R#KY#!J`}@zG zKRRQ^#M!g@|NVWxY+?J|>$?`u@0vfSck8OU4a*x>FKPYz<^1ujg-13QAKX~JcU|Sq zHPwGVpWixBdFv$QUDMV6JYPJoQfyhH)Uqb2rA<=ny5xV~ZJt>o{Qv)d1{^@~CkrD3 zgE@l^NFL-T2DYgOW*2yf?CM&!{CUi{`e28aV3Q;hBa@_vnUsqXS05vT1Oo#LOSiK!AD{5V*}}7w zT~q`F<_IrY!l~jS$H6g2V!iM>ITr=q9YPZ)?@(}2rRdg)&M&AxHbR) literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/ctool16/newhfile_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/ctool16/newhfile_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..9d1fe9f7be5f2a6b0685a3085a4c58ab4de6c931 GIT binary patch literal 379 zcmZ?wbhEHb6krfwxXQp_Z@=H$`*3~z{!d?jfBW(0*YCeSfBm`l;>VLWKcBz*`S#PV zJI}x0fBEC#s~@jE{QU9j@3VJ5KYabY?9_+vzy5yx@%#JF-@pI-ji0}N|NZ^v&L5pI zW8&;t{r~>HU$(IQ?)6=Z=XcGY)4O$5-G=3jtCzI?{c`^J*1{v3iw|xr-@C4I=bGxj zpU-cdsJwNO@~-J>f1WR%S1GovQEFL})Y2xYbzSnm?>5gY5&r-GKLc){_>+Z^fx(PH z2c!h#CkD0|4zmk9M7DJ;U9#!P$1N7e6HhuU730ztYdxexMXf$ zZ!}YzO?nX<^BGp-3Y$0+eHTqZK_Le5R$*aNNf$*fu6FS$5-coz&PsfI?Lcdo<|w%+ z3kXaWU}6y9RCbZ&;F!!I&ag?=MV^;;GViuM@-7NIJd=60@vtknNOPaRa8df~#jD(x PouzKwzH`gTk--`ObMddI literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/dtool16/newcfile_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/dtool16/newcfile_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..8928b5a2167f9d7fc9edfede79e61e7d6c19ae40 GIT binary patch literal 240 zcmVVLWKcBz*`S#PV zJI}x0fBEC#s~@jE{QU9j@3VJ5KYaadU%!9ZsSn?O{r&pm_xGQ_fB*R#KY#!J`}@zG zKRRQ^#M!g@|NVWxY+?J|>$?`u@0vfSck8OU4a*x>FKPYz<^1ujg-13QAKX~JcU|Sq zHPwGVpWixBdFv$QUDMV6JYPJoQfyhH)Uqb2rA<=ny5xV~ZJt>o{Qv)d1{^@~CkrD3 zgE@l^NFL-T2DYgOW*2yf?CM&!{CUi{`e28aV3Q;hBa@_vnUsqXS05vT1Oo#LOSiK!AD{5V*}}7w zT~q`F<_IrY!l~jS$H6g2V!iM>ITr=q9YPZ)?@(}2rRdg)&M&AxHbR) literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/etool16/newhfile_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/etool16/newhfile_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..9d1fe9f7be5f2a6b0685a3085a4c58ab4de6c931 GIT binary patch literal 379 zcmZ?wbhEHb6krfwxXQp_Z@=H$`*3~z{!d?jfBW(0*YCeSfBm`l;>VLWKcBz*`S#PV zJI}x0fBEC#s~@jE{QU9j@3VJ5KYabY?9_+vzy5yx@%#JF-@pI-ji0}N|NZ^v&L5pI zW8&;t{r~>HU$(IQ?)6=Z=XcGY)4O$5-G=3jtCzI?{c`^J*1{v3iw|xr-@C4I=bGxj zpU-cdsJwNO@~-J>f1WR%S1GovQEFL})Y2xYbzSnm?>5gY5&r-GKLc){_>+Z^fx(PH z2c!h#CkD0|4zmk9M7DJ;U9#!P$1N7e6HhuU730ztYdxexMXf$ zZ!}YzO?nX<^BGp-3Y$0+eHTqZK_Le5R$*aNNf$*fu6FS$5-coz&PsfI?Lcdo<|w%+ z3kXaWU}6y9RCbZ&;F!!I&ag?=MV^;;GViuM@-7NIJd=60@vtknNOPaRa8df~#jD(x PouzKwzH`gTk--`ObMddI literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/wizban/newcfile_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/wizban/newcfile_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..1f91a8d329b912f9d30119be3b64f323802f2715 GIT binary patch literal 2811 zcmb7F`9IT-AD?^9CfCSKIz&j(^$GcuTrE^8XCKMcp(vFKb0xVxDpA@9iIAL0IY-Vp zra8tg+iYetw!JrF-#&lB_xbzt@p?Ru*W-Em%qjcB!EPWY5FZ2*i^T$=h_)h}rvM}( zX$Uno`U^8Q^m}|{8b43LPT{8}=P?sF+}z?cmN+}RNFpt5ZHeb_)FnD=9=}8&E#rv{ z9)E*MTb^53B2n0QGJAovLS^t4X{%iRrf_3RAlw85B0jLO!s0A5*)*nb>CZXhGGURm z#uYA50Rjym(FMdMfV9M?GKFM1pGf1TLB=w;eMy5!ZIU1hIA=}0byhT@J~j8Xp(eVAr)P-_Cg+a{ zd?C8mXqYC(T#pdnwz&cP zu8QUk{)=r&1;!DKf#NkhYId-RGSxxH4bq4+l=4e!U$4!72&7bpvRiI1evMiC`IOlX zr}h+*CVnow^XAtCusU<7s1iZ#wUVOzwLjHZ7+snjW3Q};M4~@s2K}Ef5=cvcKrGO{ z|9JoX1PCk!Nq}`->JXi9u-aZf7c0qhlata`Z(Y6+dwh-VIIDMzmGot+nI!vqg_!hZ z8G3(`Mw7?n(sy~jJ=R)p)(iG{6%W8dPPxB1uyaN?1Cl)Q`eZ1OsqM3StYV*m#n`1} zuxiOqNA5;?w;9BOtnUY9w&tt+dw|K1F)lBX9Yd)_4A0ky0` ze+RR3mw~Q7)+p=H+?*XuZG)+GMP)16?rlPz-bKR)6l8_|qm{$p;N*KDBoF(!w{U}0 zZO(mXRXs@nc^$PF3OfKU?C*QXY}Z=IxQ9KLriZteGC5#4`H^tTp0e97;ut+;+;Q0S zqv0cEefi+L*vT;$J&L=UhaEb|WM{bPdBMWVCXLgtAQlZdu-AblVISiC>wH5^Vr=iI z*yH0$U)a)JenHdjJWOA_5m#T=1u9Uktyfe4Z|2~PI*JY4TI z5teFzyDu z?~kwPrt5!j&%KZty{vw1_h7Zkk^D|6xqD&to=06wk;#UJCSMm+&7MAzQnd<7Oc~f` z9(A)@H(ajTjG9UwTw%llmgMyXW1 zBg(1oV|qxh)@;?PL3pj+Glly>_$KRYU8CmDc0(PxxVW?JoO#QC-dWY|a;{d(L#s`nq$%VyJn57% zg#=}i?aUe{7w=O8VyW#XL~U#hyK!)P0ZcMuS8=k9E40#%B?6mtcsW_Sk4Eo+wM70n z&a&F&?EYPAqQKy<#2=Cmom7Y6y)u5$62LPk=f19b03Yi0C)@k~_q3*P<`3NrITKeL^Dr+l1m zm#kEJ``Dzh5Ju?bKg-Q@wI%t76reW4b24P*Q&&A-A96#Csyjvbo0}#&AIm$J&Hswv zeE|AKjZC5CCw2AN5Ls`;t?hsN_3m-8K6P3aujTPwPd&1~U0Gimsy*>x#_K*EC1=&&_Lpsc+9`7c zjdYKtCD`|B!=W8WyxB&9RRBtD%q}gk|i6?bTgANU?%b*uR-Sz;Jf5 zT$&Cv=3VsdY$qH<`j9jMY1cq@jQesX{K;7QKG81y$BFQ)hxk%`c9Khb5InCiMruc$ z1YDo)zTgq_D%J-fb&&277=|ym_ek`N&G1qI@}+j;5>8%`?@wYI$L8V_hw~1~gdU7k zI?~^*ag3d&O0L(^=>K%VA|a{fA*RX!m$1XP4)wq+Su4QZQ70Y^Z)(EGT}ZFesOga4 zUBcwIBN77mu8B$jw^kbgQm_w_(uUcTjN0~Fat?bJQoOX3)1yKR9Hs~Ua*)(^a8wA% zkvU;JRhAJO0CijPJx1@6_~>B~p@9btgeFMcOqVdP*nO^7oRlkf&T6W@KqJMP4U*T! z&@7-1b3~gUiRzaig(w)@z}Xu9o;&Y&PxaLPy7S5rGzq`YXt)C2s72f(BZ+dGCmk`A z+Vio~YL~qKp`<3mww8aw4`wJzVSj_<910fy-?&R-}OjMl+R*aXv zlQ4Wa2i#+DFC4@P7@{B5!1@cyA|VCy=W+^|G+;k3RlCl+5nPWSTG@k~Lj ze>#YZ2)wU@)wo$&eNr#n>#T4J4srbS@^KYjsSk5Gl`EU(v3$8m2h(~Xw)xS!Yp0$c vjU-z(H{N)$62dCPEZpN&!8cpup0>`Qel#{UKfV=8ZNn93-7A-r1Reb!Z;bPN literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/wizban/newhfile_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/wizban/newhfile_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..d610654ab3820690a169533ae6a03832a279b25a GIT binary patch literal 2825 zcmb`Gi9geg1ING2G0IGIkT6$r#Y3)?BT1qZl}e6Ct`bVRewq7`Tn|x>pD9T>My^OU z*WCAVgl%Sr%^0)W@$2~?exE;wpvCAyL=a+--qyhcDRX@wd1<;p*DP3WG^y2$uiMEv^tq zYb>?^N8u5uJR*(1xXdFib14kL5{i3_xyvmx;)Hk7tNjtl{G3l>AH8s??w!m{T(%xt1f5>a?XhHY1mQ}p( z>HRS{&{kJd&{|)J9c}OZffz=8n4d&1O?ObSjr6%L0lsxx$ea2a!5;W$x-p42UPA9L zX5o8&4>Xd0p=k31)WuoyryHzqcNaeTkShb3%@0Z69yNj<|06KIma;yxQm@^fS2i^+Dfw8r`@oTI#l!nQ2FN+3kgx_?D=EU(avL=OpTy z5oNyxM?{Nz}^Kh-d(-xDZ7{`O1jFar{jnJ z$_X4&GJh~z4;vl2X%ZlQZWo>Yy*GMxzJhZkNWxOX`zfWY+*^r(KI(JWYp{066gy`Q zl@~G&-h%8zm>0%oAGxmfl#D1>dA@21_DhIzih5&)jg41LQrvjrAa_KRhq%{63d}SH zzt6`!W3(N_rA7_HFv>H^Ab(@E$N}Ji`7DKW zKc)`Z0pvq6p~li1Y7&a>ZZO^b?k>g>iUB!rM`$(6Ec zMs}3F3v8))b~iyTQK47;@L2^vDpW%8UWsoPEHa4r#=K5@A}C39`es>fgB%PctDhs( zL!v`cp~eoMVggD6-Ya5Y$u57L-$#g%hn$%9bRRNOH1wla;UN*C#Rko8)n)CUUI*KE z@+#DSIQJWexBcU!e%_Msg5_fHaub$rqy%wczFOR2o+*|({-U~*ref-nbu~7kQsIuy zKqbT~1r3snagm?6|gP7HwlY!(Ta>u4KXu6pv4rD_l8)I2kgjVQHMfmvLZa`s%5pD0)WzlX*i zutFbfM3exVPwalS>4zRx&XH`7ZMI6t+=sAL+1RzeoXUHHf*XVp4DU3zDMp9CDx|AI zWIOiQ`?>7P^2N#O)&A`Yj)3Yp+}Q_0c1f9KCH?q@pzI_;y%kpDZ#pb!c$Z5pohX&M zqwKG^rhdkB<9NKgX^LTWz7=PTkep%BeN4#@V{8?f!TVamEd}?Ez#I;KrXyw#putNB zrfAwnhoj1tj$TH_PcBu$c&0I#UI8xuNUmsVxmm=yrDx|Dm}=c>L|rgL!X;1&aZnFV z{2^b0xHL!<;Gwi3J38rEM zgn9jvUC8BRj)CE`gQG`nKo4Cn@0b8hD7e!p+bgn<2p?}F;m+4v;4;&(cCz=inc5+j zsmHS6=eDRe;RtxKz*O8;Jmi9OrW!iWHSxvX!h}96z7{ zuJk>Y3GYxc11Z>wNQS9_oE<0MNgxtk33={Cv_}VIdcy)$Q8UA*ZABGr?W6-@6KzgM zf68)IyT}T<;WgYLf_!5TwjU1+?*_(#LQ~+nWjbTM&TFF9v2nF;yY+Qq;gU|iexZKo zSh7`~$exlaF*o0Mr7a-!kaZOgV!x*_+OGPZ#TnU^n~5qOC6NAxFnuU$fnz@Hq*UlnAs0kn%vu*fT%)ueHwi)-|@PK0Yg={Q{7%Mv300 z0y2d`Xj9#WCego9mc>kIF!y?gxNR&*r$odM342wsX%r6I6B~sTg=z(f>qid~RfIf@ zZBnA%UL*iI441i=RvWBneJR;m1ge=2NT>mDF;9NKXHQ*V(+|?f&64hjQG3*nPd=Hd-x zg|I=fPtj4G`-^z_OSXCMa$$}vgnU(yR=Qag44C=M4x!~xC$M3QaFWt%SHyjT=mbG8DANG--?rY q;5+bqw!86hOKlPT?yCp5;2pF2c-PfP$+=ljyZM) + + + + + + %NewWizards.sourceFile.description + + + + + + + + %NewWizards.headerFile.description + + + + + + + + %NewWizards.file.description + + - + %NewWizards.class.description + + + + + + %NewWizards.sourceFile.description + + + + + + + + %NewWizards.headerFile.description + + + + + + + + %NewWizards.file.description + + + tooltip="%NewTypeDropDownAction.tooltip"> + class="org.eclipse.cdt.internal.ui.wizards.NewFileDropDownAction" + disabledIcon="icons/full/dtool16/newcfile_wiz.gif" + icon="icons/full/etool16/newcfile_wiz.gif" + label="%NewFileDropDownAction.label" + pulldown="true" + tooltip="%NewFileDropDownAction.tooltip"> + tooltip="%NewProjectDropDownAction.tooltip"> diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java index b85fa660001..77d04e7e168 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java @@ -200,6 +200,9 @@ public class CPluginImages { public static final ImageDescriptor DESC_WIZABAN_NEW_PROJ= create(T_WIZBAN, "newcprj_wiz.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= create(T_WIZBAN, "newclass_wiz.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_WIZABAN_C_APP= create(T_WIZBAN, "c_app_wiz.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_WIZBAN_NEW_FILE= create(T_WIZBAN, "newfile_wiz.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_WIZBAN_NEW_HEADERFILE= create(T_WIZBAN, "newhfile_wiz.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_WIZBAN_NEW_SOURCEFILE= create(T_WIZBAN, "newcfile_wiz.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_TOOL_NEWCLASS= create(T_TOOL, "newclass_wiz.gif"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java index 96c83eb3501..d17f7e628f2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java @@ -12,10 +12,10 @@ package org.eclipse.cdt.internal.ui.wizards; import java.util.Iterator; -import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -24,10 +24,15 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.IWorkbenchWizard; @@ -118,10 +123,20 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe ISelection selection= window.getSelectionService().getSelection(); if (selection instanceof IStructuredSelection) { return (IStructuredSelection) selection; + } else { + // Build the selection from the IFile of the editor + IWorkbenchPart part = window.getPartService().getActivePart(); + if (part instanceof IEditorPart) { + IEditorInput input = ((IEditorPart) part).getEditorInput(); + if (input instanceof IFileEditorInput) { + IFile file = ((IFileEditorInput) input).getFile(); + if (file != null) + return new StructuredSelection(file); + } + } } - } - return null; + return StructuredSelection.EMPTY; } /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java index 951dda03bbd..e3f2c3c12c7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.wizards; -import java.util.ArrayList; - -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IRegistryChangeEvent; +import org.eclipse.core.runtime.IRegistryChangeListener; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; @@ -25,25 +22,47 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.IWorkbenchConstants; public abstract class AbstractWizardDropDownAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 { - private final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$ - private final static String ATT_CATEGORY = "category";//$NON-NLS-1$ + protected final static IAction[] NO_ACTIONS = new IAction[0]; private Menu fMenu; + private IAction[] fActions; + private IRegistryChangeListener fListener; public AbstractWizardDropDownAction() { fMenu= null; + fActions= null; setMenuCreator(this); + + // listen for changes to wizard extensions + fListener = new IRegistryChangeListener() { + public void registryChanged(IRegistryChangeEvent event) { + refreshActions(); + } + }; + Platform.getExtensionRegistry().addRegistryChangeListener(fListener); + } + + public void refreshActions() { + // force menu and actions to be created again + fActions = null; + if (fMenu != null) { + fMenu.dispose(); + fMenu = null; + } } public void dispose() { + if (fListener != null) { + Platform.getExtensionRegistry().removeRegistryChangeListener(fListener); + fListener= null; + } if (fMenu != null) { fMenu.dispose(); fMenu= null; } + fActions= null; } public Menu getMenu(Menu parent) { @@ -53,67 +72,52 @@ public abstract class AbstractWizardDropDownAction extends Action implements IMe public Menu getMenu(Control parent) { if (fMenu == null) { fMenu= new Menu(parent); - - Action[] actions= getActionFromDescriptors(); + IAction[] actions= getActions(); for (int i= 0; i < actions.length; i++) { ActionContributionItem item= new ActionContributionItem(actions[i]); item.fill(fMenu, -1); - } - + } } return fMenu; } public void run() { - // for now, just run the first available action - Action[] actions = getActionFromDescriptors(); - if (actions != null) { - for (int i = 0; i < actions.length; ++i) { - AbstractOpenWizardAction action = (AbstractOpenWizardAction) actions[0]; - if (action.isEnabled()) { - action.run(); - return; - } - } - } + // for now, run the default action + // we might want the last run action at some point + IAction action = getDefaultAction(); + if (action != null) { + action.run(); + } } - public Action[] getActionFromDescriptors() { - ArrayList CActions = new ArrayList(); - ArrayList CCActions = new ArrayList(); - - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, IWorkbenchConstants.PL_NEW); - if (extensionPoint != null) { - IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (element.getName().equals(TAG_WIZARD)) { - String category = element.getAttribute(ATT_CATEGORY); - if (category != null) { - if (category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID)) { - AbstractOpenWizardAction action = createWizardAction(element); - if (action != null) { - CCActions.add(action); - } - } else if (category.equals(CUIPlugin.CWIZARD_CATEGORY_ID)) { - AbstractOpenWizardAction action = createWizardAction(element); - if (action != null) { - CActions.add(action); - } - } - } - } - } + public IAction getDefaultAction() { + IAction[] actions = getActions(); + if (actions.length > 0) { + actions[0].getId(); + return actions[0]; +// for (int i = 0; i < actions.length; ++i) { +// IAction action = actions[i]; +// if (action.isEnabled()) { +// return action; +// } +// } } + return null; + } + + private IAction[] getActions() { + if (fActions == null) { + fActions = getWizardActions(); + if (fActions == null) + fActions = NO_ACTIONS; - //TODO: check for duplicate actions - // show C actions, then C++ Actions - CActions.addAll(CCActions); - return (Action[]) CActions.toArray(new Action[CActions.size()]); + //TODO provide a way to sort the actions + } + return fActions; } - public abstract AbstractOpenWizardAction createWizardAction(IConfigurationElement element); - + protected abstract IAction[] getWizardActions(); + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/BaseClassSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/BaseClassSelectionDialog.java index c88f401f1fb..18d0698806a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/BaseClassSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/BaseClassSelectionDialog.java @@ -18,6 +18,8 @@ import org.eclipse.swt.widgets.Shell; /** * A dialog to select a type from a list of types. The selected type will be * opened in the editor. + * + * @deprecated use NewBaseClassSelectionDialog instead */ public class BaseClassSelectionDialog extends TypeSelectionDialog { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java new file mode 100644 index 00000000000..38c6bfbd5de --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java @@ -0,0 +1,350 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Common Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: QNX Software Systems - initial API and implementation + ******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.internal.IWorkbenchConstants; + +/** + * Convenience class for drop-in C/C++ Wizard contributions. + */ +public class CWizardRegistry { + + private final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$ + private final static String ATT_CATEGORY = "category";//$NON-NLS-1$ + private final static String ATT_PROJECT = "project";//$NON-NLS-1$ + private final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$ + private final static String TAG_NAME = "name";//$NON-NLS-1$ + private final static String TAG_VALUE = "value";//$NON-NLS-1$ + private final static String ATT_CTYPE = "ctype";//$NON-NLS-1$ + private final static String ATT_CFILE = "cfile";//$NON-NLS-1$ + private final static String ATT_CPROJECT = "cproject";//$NON-NLS-1$ + private final static String ATT_CCPROJECT = "ccproject";//$NON-NLS-1$ + + /** + * Checks if wizard supports C projects. + * + * @param element the wizard element + * + * @return true if the given wizard element applies to a C Project + */ + public static boolean isCProjectWizard(IConfigurationElement element) { + String category = element.getAttribute(ATT_CATEGORY); + return (category != null && category.equals(CUIPlugin.CWIZARD_CATEGORY_ID)); + } + + /** + * Checks if wizard supports C++ project. + * + * @param element the wizard element + * + * @return true if the given wizard element applies to a C++ Project + */ + public static boolean isCCProjectWizard(IConfigurationElement element) { + String category = element.getAttribute(ATT_CATEGORY); + return (category != null && category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID)); + } + + /** + * Returns IDs of all C/C++ project wizards contributed to the workbench. + * + * @return an array of wizard ids + */ + public static String[] getProjectWizardIDs() { + return getWizardIDs(getProjectWizardElements()); + } + + /** + * Returns extension data for all the C/C++ project wizards contributed to the workbench. + * + * + * My C Wizard + * + * + * + * + * @return an array of IConfigurationElement + */ + public static IConfigurationElement[] getProjectWizardElements() { + List elemList = new ArrayList(); + IConfigurationElement[] elements = getAllWizardElements(); + for (int i = 0; i < elements.length; ++i) { + IConfigurationElement element = elements[i]; + if (isProjectWizard(element)) { + elemList.add(element); + } + } + return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]); + } + + private static boolean isProjectWizard(IConfigurationElement element) { + String project = element.getAttribute(ATT_PROJECT); + if (project != null) { + return Boolean.valueOf(project).booleanValue(); + } + + IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS); + if (classElements.length > 0) { + for (int i = 0; i < classElements.length; i++) { + IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER); + for (int k = 0; k < paramElements.length; k++) { + IConfigurationElement curr = paramElements[k]; + String name = curr.getAttribute(TAG_NAME); + if (name != null && (name.equals(ATT_CPROJECT) || name.equals(ATT_CCPROJECT))) { + String value = curr.getAttribute(TAG_VALUE); + if (value != null) + return Boolean.valueOf(value).booleanValue(); + } + } + } + return false; + } else { + // fall back, if no element found then assume it's a project wizard + return true; + } + } + + public static IAction[] getProjectWizardActions() { + return createActions(getProjectWizardElements()); + } + + /** + * Returns IDs of all C/C++ type wizards contributed to the workbench. + * + * @return an array of wizard ids + */ + public static String[] getTypeWizardIDs() { + return getWizardIDs(getTypeWizardElements()); + } + + /** + * Returns extension data for all the C/C++ type wizards contributed to the workbench. + * + * + * + * + * + * My C Wizard + * + * + * + * @return an array of IConfigurationElement + */ + public static IConfigurationElement[] getTypeWizardElements() { + List elemList = new ArrayList(); + IConfigurationElement[] elements = getAllWizardElements(); + for (int i = 0; i < elements.length; ++i) { + IConfigurationElement element = elements[i]; + if (isTypeWizard(element)) { + elemList.add(element); + } + } + return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]); + } + + private static boolean isTypeWizard(IConfigurationElement element) { + IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS); + if (classElements.length > 0) { + for (int i = 0; i < classElements.length; i++) { + IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER); + for (int k = 0; k < paramElements.length; k++) { + IConfigurationElement curr = paramElements[k]; + String name = curr.getAttribute(TAG_NAME); + if (name != null && name.equals(ATT_CTYPE)) { + String value = curr.getAttribute(TAG_VALUE); + if (value != null) + return Boolean.valueOf(value).booleanValue(); + } + } + } + } + return false; + } + + public static IAction[] getTypeWizardActions() { + return createActions(getTypeWizardElements()); + } + + /** + * Returns IDs of all C/C++ file wizards contributed to the workbench. + * + * @return an array of wizard ids + */ + public static String[] getFileWizardIDs() { + return getWizardIDs(getFileWizardElements()); + } + + /** + * Returns extension data for all the C/C++ file wizards contributed to the workbench. + * + * + * + * + * + * My C File Wizard + * + * + * + * @return an array of IConfigurationElement + */ + public static IConfigurationElement[] getFileWizardElements() { + List elemList = new ArrayList(); + IConfigurationElement[] elements = getAllWizardElements(); + for (int i = 0; i < elements.length; ++i) { + IConfigurationElement element = elements[i]; + if (isFileWizard(element)) { + elemList.add(element); + } + } + return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]); + } + + private static boolean isFileWizard(IConfigurationElement element) { + IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS); + if (classElements.length > 0) { + for (int i = 0; i < classElements.length; i++) { + IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER); + for (int k = 0; k < paramElements.length; k++) { + IConfigurationElement curr = paramElements[k]; + String name = curr.getAttribute(TAG_NAME); + if (name != null && name.equals(ATT_CFILE)) { + String value = curr.getAttribute(TAG_VALUE); + if (value != null) + return Boolean.valueOf(value).booleanValue(); + } + } + } + } + return false; + } + + public static IAction[] getFileWizardActions() { + return createActions(getFileWizardElements()); + } + + private static String[] getWizardIDs(IConfigurationElement[] elements) { + List idList = new ArrayList(); + + // add C wizards first + for (int i = 0; i < elements.length; ++i) { + IConfigurationElement element= elements[i]; + if (isCProjectWizard(element)) { + String id = element.getAttribute(IWorkbenchConstants.TAG_ID); + if (id != null && !idList.contains(id)) { + idList.add(id); + } + } + } + // now add C++ wizards + for (int i = 0; i < elements.length; ++i) { + IConfigurationElement element= elements[i]; + if (isCCProjectWizard(element)) { + String id = element.getAttribute(IWorkbenchConstants.TAG_ID); + if (id != null && !idList.contains(id)) { + idList.add(id); + } + } + } + + return (String[]) idList.toArray(new String[idList.size()]); + } + + private static IAction[] createActions(IConfigurationElement[] elements) { + List idList = new ArrayList(); + List actionList = new ArrayList(); + + // add C wizards first + for (int i = 0; i < elements.length; ++i) { + IConfigurationElement element = elements[i]; + if (isCProjectWizard(element)) { + String id = element.getAttribute(IWorkbenchConstants.TAG_ID); + if (id != null && !idList.contains(id)) { + idList.add(id); + IAction action = new OpenNewWizardAction(element); + if (action != null) { + actionList.add(action); + } + } + } + } + // now add C++ wizards + for (int i = 0; i < elements.length; ++i) { + IConfigurationElement element = elements[i]; + if (isCCProjectWizard(element)) { + String id = element.getAttribute(IWorkbenchConstants.TAG_ID); + if (id != null && !idList.contains(id)) { + idList.add(id); + IAction action = new OpenNewWizardAction(element); + if (action != null) { + actionList.add(action); + } + } + } + } + + return (IAction[]) actionList.toArray(new IAction[actionList.size()]); + } + + /** + * Returns extension data for all the C/C++ wizards contributed to the workbench. + * + * + * My C Wizard + * + * + * + * @return an array of IConfigurationElement + */ + public static IConfigurationElement[] getAllWizardElements() { + List elemList = new ArrayList(); + IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, IWorkbenchConstants.PL_NEW); + if (extensionPoint != null) { + IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); + for (int i = 0; i < elements.length; i++) { + IConfigurationElement element= elements[i]; + if (element.getName().equals(TAG_WIZARD)) { + String category = element.getAttribute(ATT_CATEGORY); + if (category != null && + (category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID) + || category.equals(CUIPlugin.CWIZARD_CATEGORY_ID))) { + elemList.add(element); + } + } + } + } + return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java new file mode 100644 index 00000000000..1ceb86b3a12 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Common Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: QNX Software Systems - initial API and implementation + ******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards; + +import org.eclipse.jface.action.IAction; + +public class NewFileDropDownAction extends AbstractWizardDropDownAction { + + public NewFileDropDownAction() { + super(); +// WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_FILE_WIZARD_ACTION); + } + + protected IAction[] getWizardActions() { + return CWizardRegistry.getFileWizardActions(); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java index 026679f343d..4366d1c6df6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java @@ -11,92 +11,17 @@ package org.eclipse.cdt.internal.ui.wizards; import org.eclipse.cdt.internal.ui.ICHelpContextIds; -import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.action.IAction; import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.internal.IWorkbenchConstants; -/* - * - * - * - * - * - * My C Wizard - * - * - * - * for backward compatibility: - * - * - * My C Wizard - * - * - */ public class NewProjectDropDownAction extends AbstractWizardDropDownAction { - private final static String ATT_PROJECT = "project";//$NON-NLS-1$ - private final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$ - private final static String TAG_NAME = "name";//$NON-NLS-1$ - private final static String TAG_VALUE = "value";//$NON-NLS-1$ - private final static String ATT_CPROJECT = "cproject";//$NON-NLS-1$ - private final static String ATT_CCPROJECT = "ccproject";//$NON-NLS-1$ - public NewProjectDropDownAction() { super(); WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_PROJECT_WIZARD_ACTION); } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.ui.wizards.AbstractWizardDropDownAction#createWizardAction(org.eclipse.core.runtime.IConfigurationElement) - */ - public AbstractOpenWizardAction createWizardAction(IConfigurationElement element) { - if (isProjectWizard(element)) { - return new OpenNewWizardAction(element); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.ui.wizards.AbstractWizardDropDownAction#isValidWizard(org.eclipse.core.runtime.IConfigurationElement) - */ - private static boolean isProjectWizard(IConfigurationElement element) { - boolean isProject = false; - String project = element.getAttribute(ATT_PROJECT); - if (project != null) - isProject = Boolean.valueOf(project).booleanValue(); - if (!isProject) - return false; - - IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS); - if (classElements.length > 0) { - for (int i = 0; i < classElements.length; i++) { - IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER); - for (int k = 0; k < paramElements.length; k++) { - IConfigurationElement curr = paramElements[k]; - String name = curr.getAttribute(TAG_NAME); - if (name != null && (name.equals(ATT_CPROJECT) || name.equals(ATT_CCPROJECT))) { - String value = curr.getAttribute(TAG_VALUE); - if (value != null) - return Boolean.valueOf(value).booleanValue(); - } - } - } - return false; - } else { - // fall back, if no element found then assume it's a project wizard - return true; - } - } + + protected IAction[] getWizardActions() { + return CWizardRegistry.getProjectWizardActions(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java index 325a93b5d08..57a2b0f00ec 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java @@ -11,64 +11,17 @@ package org.eclipse.cdt.internal.ui.wizards; import org.eclipse.cdt.internal.ui.ICHelpContextIds; -import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.action.IAction; import org.eclipse.ui.help.WorkbenchHelp; -import org.eclipse.ui.internal.IWorkbenchConstants; -/** - * - * - * - * - * My C Wizard - * - * - */ public class NewTypeDropDownAction extends AbstractWizardDropDownAction { - private final static String ATT_CTYPE = "ctype";//$NON-NLS-1$ - private final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$ - private final static String TAG_NAME = "name";//$NON-NLS-1$ - private final static String TAG_VALUE = "value";//$NON-NLS-1$ - public NewTypeDropDownAction() { super(); WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_CLASS_WIZARD_ACTION); } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.ui.wizards.AbstractWizardDropDownAction#createWizardAction(org.eclipse.core.runtime.IConfigurationElement) - */ - public AbstractOpenWizardAction createWizardAction(IConfigurationElement element) { - if (isTypeWizard(element)) { - return new OpenNewWizardAction(element); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.ui.wizards.AbstractWizardDropDownAction#isValidWizard(org.eclipse.core.runtime.IConfigurationElement) - */ - private static boolean isTypeWizard(IConfigurationElement element) { - IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS); - if (classElements.length > 0) { - for (int i = 0; i < classElements.length; i++) { - IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER); - for (int k = 0; k < paramElements.length; k++) { - IConfigurationElement curr = paramElements[k]; - String name = curr.getAttribute(TAG_NAME); - if (name != null && name.equals(ATT_CTYPE)) { - String value = curr.getAttribute(TAG_VALUE); - if (value != null) - return Boolean.valueOf(value).booleanValue(); - } - } - } - } - return false; - } + protected IAction[] getWizardActions() { + return CWizardRegistry.getTypeWizardActions(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java index 5e84dc31b57..fe39a863027 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java @@ -18,6 +18,10 @@ import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard; import org.eclipse.cdt.ui.CUIPlugin; +/** + * @deprecated use NewFileCreationWizard instead + */ + public class OpenNewFileWizardAction extends Action implements IWorkbenchWindowActionDelegate { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java index 8cc38e1db49..b8457f17870 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java @@ -31,6 +31,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.internal.corext.util.CModelUtil; +import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -135,7 +136,7 @@ public class NewClassCodeGenerator { } if (fSourcePath != null) { - IFile sourceFile = NewSourceFileGenerator.createHeaderFile(fSourcePath, true, new SubProgressMonitor(monitor, 50)); + IFile sourceFile = NewSourceFileGenerator.createSourceFile(fSourcePath, true, new SubProgressMonitor(monitor, 50)); if (sourceFile != null) { sourceTU = (ITranslationUnit) CoreModel.getDefault().create(sourceFile); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCreationWizardPage.java index c2ea703d735..9798836dde0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCreationWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCreationWizardPage.java @@ -44,6 +44,7 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.internal.ui.util.SWTUtil; import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider; import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage; +import org.eclipse.cdt.internal.ui.wizards.SourceFolderSelectionDialog; import org.eclipse.cdt.internal.ui.wizards.classwizard.NewBaseClassSelectionDialog.ITypeSelectionListener; import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.CodeGeneratorException; import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; @@ -57,6 +58,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFie import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator; import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField; +import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -1363,7 +1365,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } if (!fileExists) { - IStatus val = validateHeaderFileName(getCurrentProject(), path.lastSegment()); + IStatus val = CConventions.validateHeaderFileName(getCurrentProject(), path.lastSegment()); if (val.getSeverity() == IStatus.ERROR) { status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.InvalidHeaderFileName", val.getMessage())); //$NON-NLS-1$ return status; @@ -1447,7 +1449,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } if (!fileExists) { - IStatus val = validateSourceFileName(getCurrentProject(), path.lastSegment()); + IStatus val = CConventions.validateSourceFileName(getCurrentProject(), path.lastSegment()); if (val.getSeverity() == IStatus.ERROR) { status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.InvalidSourceFileName", val.getMessage())); //$NON-NLS-1$ return status; @@ -1458,63 +1460,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { return status; } - //TODO should this method be part of CConventions.java? - private static IStatus validateHeaderFileName(IProject project, String name) { - IStatus val = validateFileName(name); - if (val.getSeverity() == IStatus.ERROR) { - return val; - } - - StatusInfo status = new StatusInfo(val.getSeverity(), val.getMessage()); - - if (!CoreModel.isValidHeaderUnitName(project, name)) { - status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.headerFilename.filetype")); //$NON-NLS-1$ - } - - //TODO could use a prefs option for header file naming conventions - return status; - } - - //TODO should this method be part of CConventions.java? - private static IStatus validateSourceFileName(IProject project, String name) { - IStatus val = validateFileName(name); - if (val.getSeverity() == IStatus.ERROR) { - return val; - } - - StatusInfo status = new StatusInfo(val.getSeverity(), val.getMessage()); - - if (!CoreModel.isValidSourceUnitName(project, name)) { - status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.sourceFilename.filetype")); //$NON-NLS-1$ - } - - //TODO could use a prefs option for source file naming conventions - return status; - } - - //TODO should this method be part of CConventions.java? - private static IStatus validateFileName(String name) { - StatusInfo status = new StatusInfo(); - - if (name == null || name.length() == 0) { - status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.filename.nullName")); //$NON-NLS-1$ - return status; - } - - IPath path = new Path(name); - if (!path.isValidSegment(name)) { - status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.filename.invalid")); //$NON-NLS-1$ - return status; - } - - if (name.indexOf(" ") != -1) { //$NON-NLS-1$ - status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.filename.nameWithBlanks")); //$NON-NLS-1$ - } - - //TODO could use a prefs option for file naming conventions - return status; - } - /** * Hook method that gets called when a field on this page has changed. * diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties index e171e303fbf..f471d4aafea 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties @@ -26,8 +26,6 @@ NewClassCreationWizardPage.getClasses.noclasses.message=No classes available. NewClassCreationWizardPage.sourceFolder.label=Source &Folder: NewClassCreationWizardPage.sourceFolder.button=Br&owse... -NewClassCreationWizardPage.ChooseSourceFolderDialog.title=Folder Selection -NewClassCreationWizardPage.ChooseSourceFolderDialog.description=&Choose a source folder: NewClassCreationWizardPage.error.EnterSourceFolderName=Source folder name is empty. NewClassCreationWizardPage.error.NotAFolder=''{0}'' is not a project or folder. NewClassCreationWizardPage.error.NotASourceFolder=Folder ''{0}'' is not a source folder. @@ -75,12 +73,6 @@ NewClassCreationWizardPage.error.BaseClassNotExistsInProject=Base class ''{0}'' NewClassCreationWizardPage.methodStubs.label=Method &Stubs: -NewClassCreationWizardPage.convention.filename.nullName=File name is blank -NewClassCreationWizardPage.convention.filename.invalid=File name contains illegal characters -NewClassCreationWizardPage.convention.filename.nameWithBlanks=File name contains spaces -NewClassCreationWizardPage.convention.headerFilename.filetype=File extension does not correspond to known header file types -NewClassCreationWizardPage.convention.sourceFilename.filetype=File extension does not correspond to known source file types - NewClassCreationWizardPage.error.NotAFile=''{0}'' is not a file. NewClassCreationWizardPage.error.FolderDoesNotExist=Folder ''{0}'' does not exist. NewClassCreationWizardPage.error.SourceFolderRequired=The source folder is required. @@ -179,4 +171,3 @@ NewClassCodeGeneration.createType.task.source=Creating source file.... NewClassCodeGeneration.createFile.task=Creating NewClassCodeGeneration.stub.constructor.name=Constructor NewClassCodeGeneration.stub.destructor.name=Destructor -NewClassCodeGeneration.includeGuard.suffix=_H diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java index de679fff0e9..dc0707d533c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.internal.corext.util.CModelUtil; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; -import org.eclipse.cdt.internal.ui.wizards.TypedViewerFilter; +import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter; import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java new file mode 100644 index 00000000000..a21b3ff0043 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards.filewizard; + +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.cdt.internal.ui.wizards.NewElementWizard; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +public abstract class AbstractFileCreationWizard extends NewElementWizard { + + protected AbstractFileCreationWizardPage fPage = null; + + public AbstractFileCreationWizard() { + super(); + setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_FILE); + setDialogSettings(CUIPlugin.getDefault().getDialogSettings()); + setWindowTitle(NewFileWizardMessages.getString("AbstractFileCreationWizard.title")); //$NON-NLS-1$ + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#canRunForked() + */ + protected boolean canRunForked() { + return true; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor) + */ + protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException { + fPage.createFile(monitor); // use the full progress monitor + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.wizard.IWizard#performFinish() + */ + public boolean performFinish() { + boolean res = super.performFinish(); + if (res) { + //TODO need prefs option for opening editor + boolean openInEditor = true; + + ITranslationUnit headerTU = fPage.getCreatedFileTU(); + if (headerTU != null) { + IResource resource= headerTU.getResource(); + selectAndReveal(resource); + if (openInEditor) { + openResource((IFile) resource); + } + } + } + return res; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java new file mode 100644 index 00000000000..11a50fbcac0 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java @@ -0,0 +1,583 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards.filewizard; + +import org.eclipse.cdt.core.browser.PathUtil; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICContainer; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.ISourceRoot; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.internal.corext.util.CModelUtil; +import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.cdt.internal.ui.editor.CEditor; +import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider; +import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage; +import org.eclipse.cdt.internal.ui.wizards.SourceFolderSelectionDialog; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.IStringButtonAdapter; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.views.contentoutline.ContentOutline; + +public abstract class AbstractFileCreationWizardPage extends NewElementWizardPage { + + private static final int MAX_FIELD_CHARS = 50; + + private IWorkspaceRoot fWorkspaceRoot; + + // field IDs + private static final int SOURCE_FOLDER_ID = 1; + protected static final int NEW_FILE_ID = 2; + private static final int ALL_FIELDS = SOURCE_FOLDER_ID | NEW_FILE_ID; + private int fLastFocusedField = 0; + private StringButtonDialogField fSourceFolderDialogField; + private IStatus fSourceFolderStatus; + private IStatus fNewFileStatus; + private final IStatus STATUS_OK = new StatusInfo(); + + public AbstractFileCreationWizardPage(String name) { + super(name); + + setDescription(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.description")); //$NON-NLS-1$ + + fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + + SourceFolderFieldAdapter sourceFolderAdapter = new SourceFolderFieldAdapter(); + fSourceFolderDialogField = new StringButtonDialogField(sourceFolderAdapter); + fSourceFolderDialogField.setDialogFieldListener(sourceFolderAdapter); + fSourceFolderDialogField.setLabelText(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.sourceFolder.label")); //$NON-NLS-1$ + fSourceFolderDialogField.setButtonLabel(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.sourceFolder.button")); //$NON-NLS-1$ + + fSourceFolderStatus = STATUS_OK; + fNewFileStatus = STATUS_OK; + fLastFocusedField = 0; + } + + // -------- UI Creation --------- + + public void createControl(Composite parent) { + initializeDialogUnits(parent); + + Composite composite = new Composite(parent, SWT.NONE); + int nColumns = 3; + + GridLayout layout = new GridLayout(); + layout.numColumns = nColumns; + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + composite.setFont(parent.getFont()); + + createSourceFolderControls(composite, nColumns); + + createFileControls(composite, nColumns); + + composite.layout(); + + setErrorMessage(null); + setMessage(null); + setControl(composite); + } + + /** + * Creates a separator line. Expects a GridLayout with at least 1 column. + * + * @param composite the parent composite + * @param nColumns number of columns to span + */ + protected void createSeparator(Composite composite, int nColumns) { + (new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns, convertHeightInCharsToPixels(1)); + } + + /** + * Creates the necessary controls (label, text field and browse button) to edit + * the source folder location. The method expects that the parent composite + * uses a GridLayout as its layout manager and that the + * grid layout has at least 3 columns. + * + * @param parent the parent composite + * @param nColumns the number of columns to span. This number must be + * greater or equal three + */ + protected void createSourceFolderControls(Composite parent, int nColumns) { + fSourceFolderDialogField.doFillIntoGrid(parent, nColumns); + Text textControl = fSourceFolderDialogField.getTextControl(null); + LayoutUtil.setWidthHint(textControl, getMaxFieldWidth()); + textControl.addFocusListener(new StatusFocusListener(SOURCE_FOLDER_ID)); + } + + /** + * Creates the controls for the file name field. Expects a GridLayout with at + * least 3 columns. + * + * @param composite the parent composite + * @param nColumns number of columns to span + */ + protected abstract void createFileControls(Composite parent, int nColumns); + + /** + * The wizard owning this page is responsible for calling this method with the + * current selection. The selection is used to initialize the fields of the wizard + * page. + * + * @param selection used to initialize the fields + */ + public void init(IStructuredSelection selection) { + ICElement celem = getInitialCElement(selection); + initFields(celem); + doStatusUpdate(); + } + + /** + * Utility method to inspect a selection to find a C element. + * + * @param selection the selection to be inspected + * @return a C element to be used as the initial selection, or null, + * if no C element exists in the given selection + */ + protected ICElement getInitialCElement(IStructuredSelection selection) { + ICElement celem = null; + if (selection != null && !selection.isEmpty()) { + Object selectedElement = selection.getFirstElement(); + if (selectedElement instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) selectedElement; + + celem = (ICElement) adaptable.getAdapter(ICElement.class); + if (celem == null) { + IResource resource = (IResource) adaptable.getAdapter(IResource.class); + if (resource != null && resource.getType() != IResource.ROOT) { + while (celem == null && resource.getType() != IResource.PROJECT) { + resource = resource.getParent(); + celem = (ICElement) resource.getAdapter(ICElement.class); + } + if (celem == null) { + celem = CoreModel.getDefault().create(resource); // c project + } + } + } + } + } + if (celem == null) { + IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart(); + if (part instanceof ContentOutline) { + part = CUIPlugin.getActivePage().getActiveEditor(); + } + + if (part instanceof IViewPartInputProvider) { + Object elem = ((IViewPartInputProvider)part).getViewPartInput(); + if (elem instanceof ICElement) { + celem = (ICElement) elem; + } + } + + if (celem == null && part instanceof CEditor) { + IEditorInput input = ((IEditorPart)part).getEditorInput(); + if (input != null) { + final IResource res = (IResource) input.getAdapter(IResource.class); + if (res != null && res instanceof IFile) { + celem = CoreModel.getDefault().create((IFile)res); + } + } + } + } + + if (celem == null || celem.getElementType() == ICElement.C_MODEL) { + try { + ICProject[] projects = CoreModel.create(getWorkspaceRoot()).getCProjects(); + if (projects.length == 1) { + celem = projects[0]; + } + } catch (CModelException e) { + CUIPlugin.getDefault().log(e); + } + } + return celem; + } + + /** + * Initializes all fields provided by the page with a given selection. + * + * @param elem the selection used to initialize this page or + * null if no selection was available + */ + protected void initFields(ICElement elem) { + initSourceFolder(elem); + handleFieldChanged(ALL_FIELDS); + } + + /** + * Initializes the source folder field. + * + * @param elem the C element used to compute the initial folder + */ + protected void initSourceFolder(ICElement elem) { + ICContainer folder = null; + if (elem != null) { + folder = CModelUtil.getSourceFolder(elem); + if (folder == null) { + ICProject cproject = elem.getCProject(); + if (cproject != null) { + try { + if (cproject.exists()) { + ISourceRoot[] roots = cproject.getSourceRoots(); + if (roots != null && roots.length > 0) + folder = roots[0]; + } + } catch (CModelException e) { + CUIPlugin.getDefault().log(e); + } + if (folder == null) { + folder = cproject.findSourceRoot(cproject.getResource()); + } + } + } + } + setSourceFolderFullPath(folder != null ? folder.getResource().getFullPath() : null, false); + } + + /** + * Returns the recommended maximum width for text fields (in pixels). This + * method requires that createContent has been called before this method is + * call. Subclasses may override to change the maximum width for text + * fields. + * + * @return the recommended maximum width for text fields. + */ + protected int getMaxFieldWidth() { + return convertWidthInCharsToPixels(MAX_FIELD_CHARS); + } + + /** + * Returns the test selection of the current editor. null is returned + * when the current editor does not have focus or does not return a text selection. + * @return Returns the test selection of the current editor or null. + * + * @since 3.0 + */ + protected ITextSelection getCurrentTextSelection() { + IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart(); + if (part instanceof IEditorPart) { + ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); + if (selectionProvider != null) { + ISelection selection = selectionProvider.getSelection(); + if (selection instanceof ITextSelection) { + return (ITextSelection) selection; + } + } + } + return null; + } + + /** + * Sets the focus to the source folder's text field. + */ + protected void setFocusOnSourceFolder() { + fSourceFolderDialogField.setFocus(); + } + + protected final class StatusFocusListener implements FocusListener { + private int fieldID; + + public StatusFocusListener(int fieldID) { + this.fieldID = fieldID; + } + + public void focusGained(FocusEvent e) { + fLastFocusedField = this.fieldID; + doStatusUpdate(); + } + + public void focusLost(FocusEvent e) { + fLastFocusedField = 0; + doStatusUpdate(); + } + } + + private class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener { + public void changeControlPressed(DialogField field) { + IPath oldFolderPath = getSourceFolderFullPath(); + IPath newFolderPath = chooseSourceFolder(oldFolderPath); + if (newFolderPath != null) { + IPath filePath = getFileFullPath(); + setSourceFolderFullPath(newFolderPath, false); + handleFieldChanged(ALL_FIELDS); + } + } + + public void dialogFieldChanged(DialogField field) { + handleFieldChanged(ALL_FIELDS); + } + } + + // ----------- validation ---------- + + /** + * This method is a hook which gets called after the source folder's + * text input field has changed. This default implementation updates + * the model and returns an error status. The underlying model + * is only valid if the returned status is OK. + * + * @return the model's error status + */ + protected IStatus sourceFolderChanged() { + StatusInfo status = new StatusInfo(); + + IPath folderPath = getSourceFolderFullPath(); + if (folderPath == null) { + status.setError(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.error.EnterSourceFolderName")); //$NON-NLS-1$ + return status; + } + + IResource res = fWorkspaceRoot.findMember(folderPath); + if (res != null && res.exists()) { + int resType = res.getType(); + if (resType == IResource.PROJECT || resType == IResource.FOLDER) { + IProject proj = res.getProject(); + if (!proj.isOpen()) { + status.setError(NewFileWizardMessages.getFormattedString("AbstractFileCreationWizardPage.error.NotAFolder", folderPath)); //$NON-NLS-1$ + return status; + } + if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) { + if (resType == IResource.PROJECT) { + status.setError(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.warning.NotACProject")); //$NON-NLS-1$ + return status; + } else { + status.setWarning(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.warning.NotInACProject")); //$NON-NLS-1$ + } + } + ICElement e = CoreModel.getDefault().create(res.getFullPath()); + if (CModelUtil.getSourceFolder(e) == null) { + status.setError(NewFileWizardMessages.getFormattedString("AbstractFileCreationWizardPage.error.NotASourceFolder", folderPath)); //$NON-NLS-1$ + return status; + } + } else { + status.setError(NewFileWizardMessages.getFormattedString("AbstractFileCreationWizardPage.error.NotAFolder", folderPath)); //$NON-NLS-1$ + return status; + } + } else { + status.setError(NewFileWizardMessages.getFormattedString("AbstractFileCreationWizardPage.error.FolderDoesNotExist", folderPath)); //$NON-NLS-1$ + return status; + } + + return status; + } + + /** + * Hook method that gets called when a field on this page has changed. + * + * @param fields Bitwise-OR'd ids of the fields that changed. + */ + protected void handleFieldChanged(int fields) { + if (fields == 0) + return; // no change + + if (fieldChanged(fields, SOURCE_FOLDER_ID)) { + fSourceFolderStatus = sourceFolderChanged(); + } + if (fieldChanged(fields, NEW_FILE_ID)) { + fNewFileStatus = fileNameChanged(); + } + doStatusUpdate(); + } + + private boolean fieldChanged(int fields, int fieldID) { + return ((fields & fieldID) != 0); + } + + protected void doStatusUpdate() { + // do the last focused field first + IStatus lastStatus = getLastFocusedStatus(); + + // status of all used components + IStatus[] status = new IStatus[] { + lastStatus, + (fSourceFolderStatus != lastStatus) ? fSourceFolderStatus : STATUS_OK, + (fNewFileStatus != lastStatus) ? fNewFileStatus : STATUS_OK, + }; + + // the mode severe status will be displayed and the ok button enabled/disabled. + updateStatus(status); + } + + private IStatus getLastFocusedStatus() { + switch (fLastFocusedField) { + case SOURCE_FOLDER_ID: + return fSourceFolderStatus; + case NEW_FILE_ID: + return fNewFileStatus; + default: + return STATUS_OK; + } + } + + public IPath getSourceFolderFullPath() { + String text = fSourceFolderDialogField.getText(); + if (text.length() > 0) + return new Path(text).makeAbsolute(); + return null; + } + + public void setSourceFolderFullPath(IPath folderPath, boolean update) { + String str = (folderPath != null) ? folderPath.makeRelative().toString() : ""; //.makeRelative().toString(); //$NON-NLS-1$ + fSourceFolderDialogField.setTextWithoutUpdate(str); + if (update) { + fSourceFolderDialogField.dialogFieldChanged(); + } + } + + protected IProject getCurrentProject() { + IPath folderPath = getSourceFolderFullPath(); + if (folderPath != null) { + return PathUtil.getEnclosingProject(folderPath); + } + return null; + } + + /** + * Returns the workspace root. + * + * @return the workspace root + */ + protected IWorkspaceRoot getWorkspaceRoot() { + return fWorkspaceRoot; + } + + /* + * @see WizardPage#becomesVisible + */ + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible) { + setFocus(); + } + } + + /** + * Sets the focus on the starting input field. + */ + protected abstract void setFocus(); + + private IPath chooseSourceFolder(IPath initialPath) { + ICElement initElement = getSourceFolderFromPath(initialPath); + if (initElement instanceof ISourceRoot) { + ICProject cProject = initElement.getCProject(); + ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject()); + if (projRoot != null && projRoot.equals(initElement)) + initElement = cProject; + } + + SourceFolderSelectionDialog dialog = new SourceFolderSelectionDialog(getShell()); + dialog.setInput(CoreModel.create(fWorkspaceRoot)); + dialog.setInitialSelection(initElement); + + if (dialog.open() == Window.OK) { + Object result = dialog.getFirstResult(); + if (result instanceof ICElement) { + ICElement element = (ICElement)result; + if (element instanceof ICProject) { + ICProject cproject = (ICProject)element; + ISourceRoot folder = cproject.findSourceRoot(cproject.getProject()); + if (folder != null) + return folder.getResource().getFullPath(); + } + return element.getResource().getFullPath(); + } + } + return null; + } + + private ICElement getSourceFolderFromPath(IPath path) { + if (path == null) + return null; + while (!path.isEmpty()) { + IResource res = fWorkspaceRoot.findMember(path); + if (res != null && res.exists()) { + int resType = res.getType(); + if (resType == IResource.PROJECT || resType == IResource.FOLDER) { + ICElement elem = CoreModel.getDefault().create(res.getFullPath()); + ICContainer sourceFolder = CModelUtil.getSourceFolder(elem); + if (sourceFolder != null) + return sourceFolder; + if (resType == IResource.PROJECT) { + return elem; + } + } + } + path = path.removeLastSegments(1); + } + return null; + } + + /** + * Returns the full path computed from the file name field + * and the source folder. + * + * @return the file path + */ + public abstract IPath getFileFullPath(); + + /** + * Hook method that gets called when the file name has changed. The method validates the + * file name and returns the status of the validation. + * + * @return the status of the validation + */ + protected abstract IStatus fileNameChanged(); + + /** + * Creates the new file using the entered field values. + * + * @param monitor a progress monitor to report progress. + * @throws CoreException Thrown when the creation failed. + * @throws InterruptedException Thrown when the operation was cancelled. + */ + public abstract void createFile(IProgressMonitor monitor); + + /** + * Returns the created file. The method only returns a valid translation unit + * after createFile has been called. + * + * @return the created translation unit + * @see #createFile(IProgressMonitor) + */ + public abstract ITranslationUnit getCreatedFileTU(); +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java new file mode 100644 index 00000000000..23bbb8dbd2b --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards.filewizard; + + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + + +public class NewFileWizardMessages { + + private static final String RESOURCE_BUNDLE= NewFileWizardMessages.class.getName(); + private static ResourceBundle fgResourceBundle; + static { + try { + fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); + } catch (MissingResourceException x) { + fgResourceBundle = null; + } + } + + private NewFileWizardMessages() { + } + + public static String getString(String key) { + try { + return fgResourceBundle.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } catch (NullPointerException e) { + return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + /** + * Gets a string from the resource bundle and formats it with the argument + * + * @param key the string used to get the bundle value, must not be null + */ + public static String getFormattedString(String key, Object arg) { + return MessageFormat.format(getString(key), new Object[] { arg }); + } + + /** + * Gets a string from the resource bundle and formats it with arguments + */ + public static String getFormattedString(String key, Object[] args) { + return MessageFormat.format(getString(key), args); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties new file mode 100644 index 00000000000..45d6d501a6b --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties @@ -0,0 +1,68 @@ +############################################################################### +# Copyright (c) 2004 QNX Software Systems and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Common Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/cpl-v10.html +# +# Contributors: +# QNX Software Systems - Initial API and implementation +############################################################################### + +# ------- AbstractFileCreationWizard ------- +AbstractFileCreationWizard.title= New File + +# ----------- AbstractFileCreationWizardPage ------------- +AbstractFileCreationWizardPage.error.SelectedProjectError= Error in determining the selected project. +AbstractFileCreationWizardPage.error.DefaultSourceFolderError= Error in determining the default source folder. +AbstractFileCreationWizardPage.error.NotAvailableForNonCProjects= The wizard is not available for non C/C++ projects. + +AbstractFileCreationWizardPage.sourceFolder.label=Source &Folder: +AbstractFileCreationWizardPage.sourceFolder.button=Br&owse... +AbstractFileCreationWizardPage.ChooseSourceFolderDialog.title=Folder Selection +AbstractFileCreationWizardPage.ChooseSourceFolderDialog.description=&Choose a source folder: +AbstractFileCreationWizardPage.error.EnterSourceFolderName=Source folder name is empty. +AbstractFileCreationWizardPage.error.NotAFolder=''{0}'' is not a project or folder. +AbstractFileCreationWizardPage.error.NotASourceFolder=Folder ''{0}'' is not a source folder. +AbstractFileCreationWizardPage.error.ProjectClosed=Project ''{0}'' must be accessible. +NewHeaderFileCreationWizardPagewarning.NotACProject=Folder is not a C/C++ project. +AbstractFileCreationWizardPage.warning.NotInACProject=Folder is not in a C/C++ project. + +AbstractFileCreationWizardPage.error.NotAFile=''{0}'' is not a file. +AbstractFileCreationWizardPage.error.FolderDoesNotExist=Folder ''{0}'' does not exist. +AbstractFileCreationWizardPage.error.SourceFolderRequired=The source folder is required. + +# ------- NewHeaderFileCreationWizard ------- +NewHeaderFileCreationWizard.title= New Header File + +# ------- NewSourceFileCreationWizard ------- +NewSourceFileCreationWizard.title= New Source File + +# ----------- NewHeaderFileCreationWizardPage ------------- +NewHeaderFileCreationWizardPage.title= New Header File +NewHeaderFileCreationWizardPage.description= Create a new header file. +NewHeaderFileCreationWizardPage.headerFile.label= Header File: +NewHeaderFileCreationWizardPage.error.EnterFileName=File name is empty. +NewHeaderFileCreationWizardPage.error.FileNotInSourceFolder=File must be inside source folder. +NewHeaderFileCreationWizardPage.error.FileExists=File already exists. +NewHeaderFileCreationWizardPage.error.MatchingFolderExists=A folder with the same name already exists. +NewHeaderFileCreationWizardPage.error.MatchingResourceExists=A resource with the same name already exists. +NewHeaderFileCreationWizardPage.warning.FileNameDiscouraged=File name is discouraged. {0}. +NewHeaderFileCreationWizardPage.error.InvalidFileName=File name is not valid. {0}. + +# ----------- NewSourceFileCreationWizardPage ------------- +NewSourceFileCreationWizardPage.title= New Source File +NewSourceFileCreationWizardPage.description= Create a new source file. +NewSourceFileCreationWizardPage.sourceFile.label= Source File: +NewSourceFileCreationWizardPage.error.EnterFileName=File name is empty. +NewSourceFileCreationWizardPage.error.FileNotInSourceFolder=File must be inside source folder. +NewSourceFileCreationWizardPage.error.FileExists=File already exists. +NewSourceFileCreationWizardPage.error.MatchingFolderExists=A folder with the same name already exists. +NewSourceFileCreationWizardPage.error.MatchingResourceExists=A resource with the same name already exists. +NewSourceFileCreationWizardPage.warning.FileNameDiscouraged=File name is discouraged. {0}. +NewSourceFileCreationWizardPage.error.InvalidFileName=File name is not valid. {0}. + +# ----------- NewSourceFileGenerator ------------- +NewSourceFileGenerator.createFile.task= Creating +NewSourceFileGenerator.createFile.mainTask= Creating file.... +NewSourceFileGenerator.includeGuard.suffix= _H diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java new file mode 100644 index 00000000000..4eac95c49c4 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards.filewizard; + +import java.io.File; + +import org.eclipse.cdt.core.CConventions; +import org.eclipse.cdt.core.browser.PathUtil; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; + +public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardPage { + + private ITranslationUnit fNewFileTU = null; + private StringDialogField fNewFileDialogField; + + public NewHeaderFileCreationWizardPage() { + super(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.title")); + setDescription(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.description")); //$NON-NLS-1$ + + fNewFileDialogField = new StringDialogField(); + fNewFileDialogField.setDialogFieldListener(new IDialogFieldListener() { + public void dialogFieldChanged(DialogField field) { + handleFieldChanged(NEW_FILE_ID); + } + }); + fNewFileDialogField.setLabelText(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.headerFile.label")); //$NON-NLS-1$ + } + + /** + * Sets the focus on the starting input field. + */ + protected void setFocus() { + fNewFileDialogField.setFocus(); + } + + /** + * Creates the controls for the file name field. Expects a GridLayout with at + * least 3 columns. + * + * @param composite the parent composite + * @param nColumns number of columns to span + */ + protected void createFileControls(Composite parent, int nColumns) { + fNewFileDialogField.doFillIntoGrid(parent, nColumns); + Text textControl = fNewFileDialogField.getTextControl(null); + LayoutUtil.setWidthHint(textControl, getMaxFieldWidth()); + textControl.addFocusListener(new StatusFocusListener(NEW_FILE_ID)); + } + + public IPath getFileFullPath() { + String str = fNewFileDialogField.getText(); + IPath path = null; + if (str.length() > 0) { + path = new Path(str); + if (!path.isAbsolute()) { + IPath folderPath = getSourceFolderFullPath(); + if (folderPath != null) + path = folderPath.append(path); + } + } + return path; + } + + protected IStatus fileNameChanged() { + StatusInfo status = new StatusInfo(); + + IPath filePath = getFileFullPath(); + if (filePath == null) { + status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.EnterFileName")); //$NON-NLS-1$ + return status; + } + + // check if file already exists + IPath workspacePath = getWorkspaceRoot().getLocation(); + File file = workspacePath.append(filePath).toFile(); +// if (file == null || !file.exists()) { +// IResource res = fWorkspaceRoot.findMember(path); +// if (res != null && res.exists()) { +// file = res.getLocation().toFile(); +// } +// } + if (file != null && file.exists()) { + if (file.isFile()) { + status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.FileExists")); //$NON-NLS-1$ + } else if (file.isDirectory()) { + status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.MatchingFolderExists")); //$NON-NLS-1$ + } else { + status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.MatchingResourceExists")); //$NON-NLS-1$ + } + return status; + } else if (filePath.segmentCount() > 1) { + IPath parentFolderPath = workspacePath.append(filePath).removeLastSegments(1); + File folder = parentFolderPath.toFile(); + if (folder != null && folder.exists() && folder.isDirectory()) { + // folder exists + } else { + status.setError(NewFileWizardMessages.getFormattedString("NewHeaderFileCreationWizardPage.error.FolderDoesNotExist", PathUtil.getWorkspaceRelativePath(parentFolderPath))); //$NON-NLS-1$ + return status; + } + } + + // make sure file is inside source folder + IPath folderPath = getSourceFolderFullPath(); + if (folderPath != null && !folderPath.isPrefixOf(filePath)) { + status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.FileNotInSourceFolder")); //$NON-NLS-1$ + return status; + } + + IStatus convStatus = CConventions.validateHeaderFileName(getCurrentProject(), filePath.lastSegment()); + if (convStatus.getSeverity() == IStatus.ERROR) { + status.setError(NewFileWizardMessages.getFormattedString("NewHeaderFileCreationWizardPage.error.InvalidFileName", convStatus.getMessage())); //$NON-NLS-1$ + return status; + } else if (convStatus.getSeverity() == IStatus.WARNING) { + status.setWarning(NewFileWizardMessages.getFormattedString("NewHeaderFileCreationWizardPage.warning.FileNameDiscouraged", convStatus.getMessage())); //$NON-NLS-1$ + } + return status; + } + + public void createFile(IProgressMonitor monitor) { + IPath filePath = getFileFullPath(); + if (filePath != null) { + if (monitor == null) + monitor = new NullProgressMonitor(); + try { + fNewFileTU = null; + IFile newFile = NewSourceFileGenerator.createHeaderFile(filePath, true, monitor); + if (newFile != null) { + fNewFileTU = (ITranslationUnit) CoreModel.getDefault().create(newFile); + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + monitor.done(); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getCreatedFileTU() + */ + public ITranslationUnit getCreatedFileTU() { + return fNewFileTU; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java new file mode 100644 index 00000000000..3fd52d32614 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java @@ -0,0 +1,167 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards.filewizard; + +import java.io.File; + +import org.eclipse.cdt.core.CConventions; +import org.eclipse.cdt.core.browser.PathUtil; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; + +public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardPage { + private ITranslationUnit fNewFileTU = null; + private StringDialogField fNewFileDialogField; + + public NewSourceFileCreationWizardPage() { + super(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.title")); + setDescription(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.description")); //$NON-NLS-1$ + + fNewFileDialogField = new StringDialogField(); + fNewFileDialogField.setDialogFieldListener(new IDialogFieldListener() { + public void dialogFieldChanged(DialogField field) { + handleFieldChanged(NEW_FILE_ID); + } + }); + fNewFileDialogField.setLabelText(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.sourceFile.label")); //$NON-NLS-1$ + } + + /** + * Sets the focus on the starting input field. + */ + protected void setFocus() { + fNewFileDialogField.setFocus(); + } + + /** + * Creates the controls for the file name field. Expects a GridLayout with at + * least 3 columns. + * + * @param composite the parent composite + * @param nColumns number of columns to span + */ + protected void createFileControls(Composite parent, int nColumns) { + fNewFileDialogField.doFillIntoGrid(parent, nColumns); + Text textControl = fNewFileDialogField.getTextControl(null); + LayoutUtil.setWidthHint(textControl, getMaxFieldWidth()); + textControl.addFocusListener(new StatusFocusListener(NEW_FILE_ID)); + } + + public IPath getFileFullPath() { + String str = fNewFileDialogField.getText(); + IPath path = null; + if (str.length() > 0) { + path = new Path(str); + if (!path.isAbsolute()) { + IPath folderPath = getSourceFolderFullPath(); + if (folderPath != null) + path = folderPath.append(path); + } + } + return path; + } + + protected IStatus fileNameChanged() { + StatusInfo status = new StatusInfo(); + + IPath filePath = getFileFullPath(); + if (filePath == null) { + status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.EnterFileName")); //$NON-NLS-1$ + return status; + } + + // check if file already exists + IPath workspacePath = getWorkspaceRoot().getLocation(); + File file = workspacePath.append(filePath).toFile(); +// if (file == null || !file.exists()) { +// IResource res = fWorkspaceRoot.findMember(path); +// if (res != null && res.exists()) { +// file = res.getLocation().toFile(); +// } +// } + if (file != null && file.exists()) { + if (file.isFile()) { + status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.FileExists")); //$NON-NLS-1$ + } else if (file.isDirectory()) { + status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.MatchingFolderExists")); //$NON-NLS-1$ + } else { + status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.MatchingResourceExists")); //$NON-NLS-1$ + } + return status; + } else if (filePath.segmentCount() > 1) { + IPath parentFolderPath = workspacePath.append(filePath).removeLastSegments(1); + File folder = parentFolderPath.toFile(); + if (folder != null && folder.exists() && folder.isDirectory()) { + // folder exists + } else { + status.setError(NewFileWizardMessages.getFormattedString("NewSourceFileCreationWizardPage.error.FolderDoesNotExist", PathUtil.getWorkspaceRelativePath(parentFolderPath))); //$NON-NLS-1$ + return status; + } + } + + // make sure file is inside source folder + IPath folderPath = getSourceFolderFullPath(); + if (folderPath != null && !folderPath.isPrefixOf(filePath)) { + status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.FileNotInSourceFolder")); //$NON-NLS-1$ + return status; + } + + IStatus convStatus = CConventions.validateSourceFileName(getCurrentProject(), filePath.lastSegment()); + if (convStatus.getSeverity() == IStatus.ERROR) { + status.setError(NewFileWizardMessages.getFormattedString("NewSourceFileCreationWizardPage.error.InvalidFileName", convStatus.getMessage())); //$NON-NLS-1$ + return status; + } else if (convStatus.getSeverity() == IStatus.WARNING) { + status.setWarning(NewFileWizardMessages.getFormattedString("NewSourceFileCreationWizardPage.warning.FileNameDiscouraged", convStatus.getMessage())); //$NON-NLS-1$ + } + return status; + } + + public void createFile(IProgressMonitor monitor) { + IPath filePath = getFileFullPath(); + if (filePath != null) { + if (monitor == null) + monitor = new NullProgressMonitor(); + try { + fNewFileTU = null; + IFile newFile = NewSourceFileGenerator.createSourceFile(filePath, true, monitor); + if (newFile != null) { + fNewFileTU = (ITranslationUnit) CoreModel.getDefault().create(newFile); + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + monitor.done(); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getCreatedFileTU() + */ + public ITranslationUnit getCreatedFileTU() { + return fNewFileTU; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewSourceFileGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java similarity index 95% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewSourceFileGenerator.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java index 9740bb4fead..807ed9a4cb2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewSourceFileGenerator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java @@ -8,7 +8,7 @@ * Contributors: * QNX Software Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.internal.ui.wizards.classwizard; +package org.eclipse.cdt.internal.ui.wizards.filewizard; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -94,7 +94,7 @@ public class NewSourceFileGenerator { return null; } - public static IFile createSourceFile(IPath filePath, boolean useIncludeGuard, boolean force, IProgressMonitor monitor) throws CoreException { + public static IFile createSourceFile(IPath filePath, boolean force, IProgressMonitor monitor) throws CoreException { //TODO should use code templates ByteArrayInputStream stream = new ByteArrayInputStream(new byte[0]); return createNewFile(filePath, stream, force, monitor); @@ -104,7 +104,7 @@ public class NewSourceFileGenerator { int totalWork = 100; int createFileWork = totalWork; - monitor.beginTask(NewClassWizardMessages.getString("NewClassCodeGeneration.createFile.task"), totalWork); //$NON-NLS-1$ + monitor.beginTask(NewFileWizardMessages.getString("NewSourceFileGenerator.createFile.task"), totalWork); //$NON-NLS-1$ IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot(); IFile newFile = root.getFileForLocation(newFilePath); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizard.java index 1367cbabfd0..ec0858f3cfe 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizard.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizard.java @@ -36,6 +36,7 @@ import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; /** * description for "NewClassWizard". * @see Wizard + * @deprecated use NewClassCreationWizard instead */ public class NewClassWizard extends BasicNewResourceWizard implements INewWizard { private NewClassWizardPage fPage; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java index 826e08fc59e..52390fc190e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java @@ -26,8 +26,8 @@ import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.browser.ITypeReference; import org.eclipse.cdt.core.browser.ITypeSearchScope; import org.eclipse.cdt.core.browser.QualifiedTypeName; -import org.eclipse.cdt.core.browser.UnknownTypeInfo; import org.eclipse.cdt.core.browser.TypeSearchScope; +import org.eclipse.cdt.core.browser.UnknownTypeInfo; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; @@ -48,9 +48,9 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; import org.eclipse.cdt.internal.ui.wizards.dialogfields.LinkToFileGroup; import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFieldGroup; -import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField; -import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CodeGeneration; import org.eclipse.cdt.ui.PreferenceConstants; @@ -84,7 +84,6 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.dialogs.ContainerGenerator; -import org.eclipse.ui.internal.WorkbenchPlugin; /** * Wizard page to create a new class. @@ -93,8 +92,8 @@ import org.eclipse.ui.internal.WorkbenchPlugin; * a new class wizard page, extend NewTypeWizardPage. *

* + * @deprecated use NewClassCreationWizardPage instead */ - public class NewClassWizardPage extends WizardPage implements Listener { // the page name private final static String PAGE_NAME= "NewClassWizardPage"; //$NON-NLS-1$ @@ -646,7 +645,7 @@ public class NewClassWizardPage extends WizardPage implements Listener { monitor= new NullProgressMonitor(); } - monitor.beginTask(NewWizardMessages.getString("NewTypeWizardPage.operationdesc"), 10); //$NON-NLS-1$ + monitor.beginTask(NewWizardMessages.getString("NewClassWizardPage.operationdesc"), 10); //$NON-NLS-1$ // resolve location of base class String baseClassName = getBaseClassName(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java new file mode 100644 index 00000000000..0d483650429 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.wizards; + +import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard; + +public class NewFileCreationWizard extends BasicNewFileResourceWizard { +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java new file mode 100644 index 00000000000..194c1bec3c6 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.wizards; + +import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizard; +import org.eclipse.cdt.internal.ui.wizards.filewizard.NewFileWizardMessages; +import org.eclipse.cdt.internal.ui.wizards.filewizard.NewHeaderFileCreationWizardPage; +import org.eclipse.cdt.ui.CUIPlugin; + +public class NewHeaderFileCreationWizard extends AbstractFileCreationWizard { + + public NewHeaderFileCreationWizard() { + super(); + setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_HEADERFILE); + setDialogSettings(CUIPlugin.getDefault().getDialogSettings()); + setWindowTitle(NewFileWizardMessages.getString("NewHeaderFileCreationWizard.title")); //$NON-NLS-1$ + } + + /* + * @see Wizard#createPages + */ + public void addPages() { + super.addPages(); + fPage = new NewHeaderFileCreationWizardPage(); + addPage(fPage); + fPage.init(getSelection()); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java new file mode 100644 index 00000000000..55fb1a465aa --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.wizards; + +import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizard; +import org.eclipse.cdt.internal.ui.wizards.filewizard.NewFileWizardMessages; +import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileCreationWizardPage; +import org.eclipse.cdt.ui.CUIPlugin; + +public class NewSourceFileCreationWizard extends AbstractFileCreationWizard { + + public NewSourceFileCreationWizard() { + super(); + setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_SOURCEFILE); + setDialogSettings(CUIPlugin.getDefault().getDialogSettings()); + setWindowTitle(NewFileWizardMessages.getString("NewSourceFileCreationWizard.title")); //$NON-NLS-1$ + } + + /* + * @see Wizard#createPages + */ + public void addPages() { + super.addPages(); + fPage = new NewSourceFileCreationWizardPage(); + addPage(fPage); + fPage.init(getSelection()); + } +}